in reply to How would I add a pause b/t forks in my $pid = $pm->start and next;

instead of P::FM, use Proc::Queue, it allows you to set a minimum time interval between forks:
use Proc::Queue size => 2, delay => 3.0, qw(system_back); foreach(@temp_files) { system_back("$program < $_"); } 1 while wait != -1;
  • Comment on Re: How would I add a pause b/t forks in my $pid = $pm->start and next;
  • Download Code

Replies are listed 'Best First'.
Re^2: How would I add a pause b/t forks in my $pid = $pm->start and next;
by samtregar (Abbot) on Oct 27, 2005 at 21:50 UTC
    I'd never seen Proc::Queue before and I must say it's pretty shocking. As though fork/wait/waitpid weren't complex enough it adds another layer of complexity on top of that! I can't imagine why anyone would use this instead of Paralell::ForkManager. Just looking at this code (from the synopsis) makes my teeth hurt:

    1 while waitpid(-1, WNOHANG)>0; # reaps childs

    -sam

      As though fork/wait/waitpid weren't complex enough it adds another layer of complexity on top of that

      Well, not really, Proc::Queue is completelly transparent, use it at the beginning of your script and then call fork, exit, etc. as ever.

        Sure, but I don't want to fork/waitpid/wait as usual! That stuff is way too complicated to get right most of the time. That's why Parallel::ForkManager is a better solution, it hides the complexity of forking beneath a clear and consistent API.

        -sam