Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > forking and avoiding zombies!

Reply
Thread Tools

forking and avoiding zombies!

 
 
andrea crotti
Guest
Posts: n/a
 
      12-10-2012
So I implemented a simple decorator to run a function in a forked
process, as below.

It works well but the problem is that the childs end up as zombies on
one machine, while strangely
I can't reproduce the same on mine..

I know that this is not the perfect method to spawn a daemon, but I
also wanted to keep the code
as simple as possible since other people will maintain it..

What is the easiest solution to avoid the creation of zombies and
maintain this functionality?
thanks


def on_forked_process(func):
from os import fork
"""Decorator that forks the process, runs the function and gives
back control to the main process
"""
def _on_forked_process(*args, **kwargs):
pid = fork()
if pid == 0:
func(*args, **kwargs)
_exit(0)
else:
return pid

return _on_forked_process
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: forking and avoiding zombies! andrea crotti Python 1 12-12-2012 03:23 PM
Re: forking and avoiding zombies! peter Python 1 12-11-2012 03:15 PM
Re: forking and avoiding zombies! peter Python 0 12-11-2012 12:33 PM
Re: forking and avoiding zombies! andrea crotti Python 0 12-11-2012 11:47 AM
Re: forking and avoiding zombies! peter Python 0 12-10-2012 05:00 PM



Advertisments