in reply to Maximum # of concurrent runs
Looks like your solution would iterate over the spammy email data, launching new forks each time. Don't exec() or you'll skip the important $pm->finish() call.use Parallel::ForkManager; $pm = new Parallel::ForkManager($MAX_PROCESSES); foreach $data (@all_data) { # Forks and returns the pid for the child: my $pid = $pm->start and next; ... do some work with $data in the child process ... $pm->finish; # Terminates the child process }
Update: To manage a family of processes cleanly and simply, you must be the parent. You must have some central authority process which detects new emails and launches new filter processes, and that central process must do the management.
It's not going to be as clean or supportable to try to detect how many siblings or cousins are already running before performing any work. You'd get into a big hairy ball of semaphores before you got anything working.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Maximum # of concurrent runs
by warthurton (Sexton) on Aug 19, 2003 at 16:22 UTC | |
by merlyn (Sage) on Aug 19, 2003 at 17:07 UTC |