On Ubuntu 12.04 with mod_wsgi for python 3.
I have a WSGI application (actually just a script) that happens to launch an external program with Popen for each user session (it's actually a small GTK program, I'm experimenting with its HTML5 backend).
There is a Javascript loop on the client side which send a "keep alive" signal each few seconds to the WSGI. If the WSGI did not received any signal for a session for a while, then it will kill the relative process (and delete the session).
This works well, except when I restart/reload Apache or when I edit the WSGI script (which AFAIK automatically reload the app). If I do such a thing, subprocesses are not killed. They still run (they aren't zombies) and all I can do is to kill them manually (the WSGI lost former sessions so it won't kill any "old" process).
So I would like one of the following:
- A way to notice that the server is stopping/restarting/reloading from the WSGI side, so that it can clean-up it's subprocesses while it knows them
- Spawned processes should died with mod_wsgi (currently it seems subprocesses are reattached to Init when mod_wsgi is killed/reloaded)
Here is the VirtualHost I use:
<VirtualHost *:80>
WSGIDaemonProcess deckard_qh user=deckard group=deckard threads=5
WSGIScriptAlias / /home/deckard/wsgi/deckard_qh.wsgi
Alias /ressources /home/deckard/ressources
<Directory /home/deckard/wsgi>
WSGIProcessGroup deckard_qh
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
<Directory /home/deckard/ressources>
Order deny,allow
Allow from all
</Directory>
I tried adding WSGIProcessGroup deckard
and WSGIApplicationGroup %{GLOBAL}
(as per this answer), but it did not change anything.
I also added os.setsid()
at the start of my WSGI script, but no result.