[Python-Dev] cpython: Fix closes issue #11109 - socketserver.ForkingMixIn leaves zombies, also fails

Senthil Kumaran senthil at uthcode.com
Thu May 26 07:10:55 CEST 2011

Antoine Pitrou wrote:
> >> A new method called service_action is made available in BaseServer, called by
> >> serve_forever loop. This useful in cases where Mixins can use it for cleanup
> >> action. ForkingMixin class uses service_action to collect the zombie child
> >> processes. Initial Patch by Justin Wark.
> >
> > Is it reasonable, performance-wise, to do this at every iteration of
> > the loop (that is, at every incoming connection)?

If not here, the call was being done at the process_request level when
creating a new child process and the wait would have been there. I am
not sure, how much performance different (lag) this aggressive
collection can bring.

Charles-François Natali wrote:

> I haven't measured it, but it's O(N) where N is the number of children.
> It should be possible to optimize this by putting all the children in
> a process group (the other advantage is that we wouldn't wait()
> children not spawned by socketserver).

+1. This is definitely a good idea. The change needs to be done in the
collection_children routine which tries to wait for all children to
finish instead of just the ones forked by the socketserver.
Shall raise ticket for this.


Although the moon is smaller than the earth, it is farther away.

More information about the Python-Dev mailing list