SocketServer.ForkingMixIn and zombie processes

N

nisimura

Hi,

I noticed that when I used SocketServer.ForkingMixIn
(ForkingTCPServer), there were always zombie processes around. I
searched for where waitpid() is called in ForkingMixIn and found it in
SocketServer.py:

def process_request(self, request, client_address):
"""Fork a new subprocess to process the request."""
self.collect_children()
pid = os.fork()
if pid:
# Parent process
if self.active_children is None:
self.active_children = []
self.active_children.append(pid)
self.close_request(request)
return
else:
# Child process.
# This must never return, hence os._exit()!
try:
self.finish_request(request, client_address)
os._exit(0)
except:
try:
self.handle_error(request, client_address)
finally:
os._exit(1)

So waitpid() is called just before fork(). This means that if next
request does not come in, zombie processes are not reclaimed forever!
Is this an intentional behavior? Is there any workaround?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top