Think about Loose Coupling | |
PerlMonks |
Limiting the number of forksby c (Hermit) |
on Oct 02, 2002 at 12:06 UTC ( [id://202240]=perlquestion: print w/replies, xml ) | Need Help?? |
c has asked for the wisdom of the Perl Monks concerning the following question:
A while back I first started working with using fork in a script. After a number of PM posts, I had some working code. The problem now, I guess is that it works too well. I'm curious to know how to set an upper limit on the number of forked child processes. In some instances, my script would be able to break out over 2000 that could tax my server quite a bit. I'd like to be able to have the script have no more than 50 processes at a time. I'm currently working with the following code base:
I'm not really sure at all how to achieve want I want in this case. Every solution that I have tried to come up with ends up only forking the first 50 processes and then ends up skipping the remaining in my list as my for loop just continues on its way. Can someone offer a suggestion on how I can accomplish this? thanks -c
Back to
Seekers of Perl Wisdom
|
|