This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author neologix
Recipients neologix, orsenthil, pitrou
Date 2011-05-26.12:46:21
SpamBayes Score 1.5245955e-06
Marked as misclassified No
Message-id <1306413983.8.0.405139663003.issue12184@psf.upfronthosting.co.za>
In-reply-to
Content
In the common case, I don't think that the os.waitpid(0, 0) is the hot spot, but rather this:

for child in self.active_children:
    os.waitpid(child, os.WNOHANG)

It's called every time, and it's O(number of active children).

os.waitpid(0, 0) is only called when max_children (40) is reached. Also, I'm not sure why it's called without WNOHANG, because that means that we will block until active_children falls below max_children. That's an arbitrary limit, especially since it's not documented.

I've written a first draft patch using process group, that removes active_children and max_children.
The only slightly tricky part is the call to setpgid from the child and from the parent, to avoid a race where the child could try to join a stale PGID.
Note that I assume that setpgid is available on every Unix, since according to http://pubs.opengroup.org/onlinepubs/007908799/xsh/setpgid.html , it's "Derived from the POSIX.1-1988 standard".
Also, according to buildbots' configure logs, it's available everywhere.
History
Date User Action Args
2011-05-26 12:46:23neologixsetrecipients: + neologix, orsenthil, pitrou
2011-05-26 12:46:23neologixsetmessageid: <1306413983.8.0.405139663003.issue12184@psf.upfronthosting.co.za>
2011-05-26 12:46:22neologixlinkissue12184 messages
2011-05-26 12:46:22neologixcreate