Subject: | Timing problem with multiple processes |
Date: | Mon, 16 Feb 2015 20:39:44 +0000 |
To: | "bug-WWW-Mechanize-PhantomJS [...] rt.cpan.org" <bug-WWW-Mechanize-PhantomJS [...] rt.cpan.org> |
From: | "Kelvin Price [DATACOM]" <kelvinpr [...] datacom.co.nz> |
Hi,
Firstly, thanks for a module that has greatly helped me build a website monitoring tool for our customers.
Secondly, I have found a problem when running multiple instances of scripts that use the module. What appears to be happening is that 2 or more launch PhantomJS with the same port number, only 1 will manage that successfully, but all the others will manage to connect to the first one when testing that they can connect to the port. Then when the first one finishes and kills PhantomJS, all the rest break with connection failures the next time they try to send a command and die before completing their monitoring.
I'm wondering if when trying to connect to the port, perhaps the code should also check that $options{pid} is alive (kill 0, $options{pid} ) and possibly reset $options{kill_pid} if it is not alive in order to avoid killing a new process that just happens to have the same pid as the PhantomJS that died after failing to launch with an in-use port.
Cheers,
Kelvin