in reply to Parallel::ForkManager run_on_finish() bug?

After more head-scratching I suppose my code is asking too much. I expect run_on_finish() to act asynchronously like the signal but its becoming obvious P:FM relies on being inside P::FM::start() or P::FM::wait_all_children() to execute its callbacks.

I would settle for a documentation update that clarifies that run_on_finish() is not asynchronous unless you link it to SIG{CHLD}. An optional flag to run_on_finish() that installs the SIG{CHLD} handler for you would be nice though.

  • Comment on Re: Parallel::ForkManager run_on_finish() bug?

Replies are listed 'Best First'.
Re^2: Parallel::ForkManager run_on_finish() bug?
by runrig (Abbot) on May 04, 2012 at 16:13 UTC
    wait_one_child is an undocumented method of P:FM, but it seems like that would be useful in your case. An attempt at psueudo-code:
    while ($stuff_to_do) { for my $job (@job_list) { $pm->start($job) and next; $pm->finish(); } if ($still_doing_stuff) { # run_on_finish might push more stuff to @job_list $pm->wait_one_child(); } }
      How would you use it the example code given by anshumangoyal above?
      I have the same problem on perl 5.18 and P:FM 1.03.
      I have the same code running on production for years on 5.10 and P:FM 0.7.5 without any issues.