choroba has asked for the wisdom of the Perl Monks concerning the following question:
I tried to install AnyEvent::ForkManager on Cygwin. Both its main dependencies, AnyEvent and Parallel::ForkManager, installed without problems, but the module itself hung right after the first test in 001_basic.t:
~/.cpan/build/AnyEvent-ForkManager-0.04-ZOUXbL$ ./Build test t/000_load.t ...... 1/1 # Testing AnyEvent::ForkManager/0.04 t/000_load.t ...... ok t/001_basic.t ..... 1/63
I sprinkled the code with tracing warns to discover where exactly the code gets stuck. The following line never finished:
$pm->start( cb => sub { my($pm, $exit_code) = @_; local $SIG{USR1} = sub { $started_all_process = 1; }; isnt $$, $pm->manager_pid, 'called by child'; # <<== + HERE until ($started_all_process) {}; # wait note "exit_code: $exit_code"; $pm->finish($exit_code); fail 'finish failed'; }, args => [$exit_code] );
At first, I though that's manager_pid that doesn't return, but after replacing the line with
my $mpid = $pm->manager_pid; isnt $$, $mpid, 'called by child';
it became obvious it's the isnt line that causes the issue. I delved more deeply and found out it comes from Test::SharedFork. It uses flock to lock a file that shares the information between forks. The Store::Locker is constructed with the following:
sub new { my ($class, $store) = @_; $store->_reopen_if_needed; if ($store->{lock}++ == 0) { flock $store->{fh}, LOCK_EX or die $!; # <<== HERE } bless { store => $store }, $class; }
The code stops on the flock line and stays there forever (on Linux, it works correctly). I wanted to know more, so I prepended the following to the line:
use Data::Dumper; $Data::Dumper::Deparse = 1; warn Dumper($store);
Not only was I able to see the structure, but all the tests passed. "A race condition," though I and replaced the line with
use Time::HiRes qw{ usleep }; usleep 200;
Result: PASS. When lowering the value, the tests sometimes hung again.
Thanks. The issue lives outside of PM at github, too.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: AnyEvent::ForkManager fails tests on Cygwin
by MidLifeXis (Monsignor) on Apr 30, 2015 at 13:42 UTC | |
by choroba (Cardinal) on Apr 30, 2015 at 14:04 UTC | |
by MidLifeXis (Monsignor) on Apr 30, 2015 at 15:16 UTC | |
|
Re: AnyEvent::ForkManager fails tests on Cygwin
by ikegami (Patriarch) on Apr 30, 2015 at 15:01 UTC | |
by choroba (Cardinal) on Apr 30, 2015 at 15:03 UTC | |
by ikegami (Patriarch) on May 01, 2015 at 13:41 UTC | |
|
Re: AnyEvent::ForkManager fails tests on Cygwin
by choroba (Cardinal) on May 18, 2015 at 08:21 UTC |