[issue12184] socketserver.ForkingMixin collect_children routine needs to collect only it's children
Charles-François Natali added the comment: Closing as wont't fix, since we now have asyncio which handles this much better. -- resolution: - wont fix stage: needs patch - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12184 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12184] socketserver.ForkingMixin collect_children routine needs to collect only it's children
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12184 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12184] socketserver.ForkingMixin collect_children routine needs to collect only it's children
Charles-François Natali neolo...@free.fr added the comment: 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. -- keywords: +patch Added file: http://bugs.python.org/file22124/ss_wait_group.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12184 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12184] socketserver.ForkingMixin collect_children routine needs to collect only it's children
Charles-François Natali neolo...@free.fr added the comment: Some precisions: 1) Of course, if a handler changes its process group through setsid/setpgrp, it won't be waited on. 2) If a handler running on behalf of a process which is the current process group leader calls setsid, it will get an EPERM error. I don't think anyone is using that, but I'd rather make it clear. The only way I can think of to alleviate 2 would be to spawn a dummy process that would just be used as process group leader (and since it would keep running, no need to re-allocate a new PGID when worker processes exit). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12184 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12184] socketserver.ForkingMixin collect_children routine needs to collect only it's children
New submission from Senthil Kumaran sent...@uthcode.com: socketserver.ForkingMixin class has a collect_children method, that waits for the children to exit. But, that waits for any child process and not just the ones spawned the socketserver alone. try: pid, status = os.waitpid(0, 0) except os.error: pid = None This is performance lag and can be improved. The collect_children can only wait/collect it's own children. -- messages: 136931 nosy: orsenthil, pitrou priority: normal severity: normal stage: needs patch status: open title: socketserver.ForkingMixin collect_children routine needs to collect only it's children type: resource usage versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12184 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12184] socketserver.ForkingMixin collect_children routine needs to collect only it's children
Changes by Senthil Kumaran sent...@uthcode.com: -- nosy: +charles-francois.natali ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12184 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com