Davo, I am kind of confused, you are running a command that never
stops and wondering why it never stops...

The watch command does not stop on it's own. Since watch has no option
to quit after x iterations, you must send it a signal when you are
done with it.

Perhaps you could wrap your code in a class and signal your subprocess
in the __del__ method of said class. Thus when the class is garbage
collected, the process will be signaled and exit. Or perhaps you can
accomplish what you are trying to do with another command that DOES
exit when it is done with whatever task you wish it to perform.

On May 12, 12:01 pm, Davo <[email protected]> wrote:
> Hi all,
>
> If I have a WSGI running as daemon mode and my python code is:
>
> p = subprocess.Popen(['watch -n 5 echo "aaa"'],
> stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
> shell=True).communicate()[0].strip('\n')
>
> The "watch" goes background and never ends. Even when I kill the wsgi
> daemon it still exists and changes its PPID (parent ID) to 1 (which
> means its becomes its own process instead of a child of any parent...)
> is there a way to prevent this? Cleanup all the childs or something
> when the daemon is restarted?

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to