mod_python and open HTTP connection
Kane
jason.w.kane at gmail.com
Thu Feb 16 19:35:13 EST 2006
> Does mod_python time out after a minute ?
No, but the browser may timeout. Sending a periodic bit-o-data on a
long running page is a good idea anyway (so the user knows it is still
working).
>If I leave an HTTP connection open so that the content keeps loading inside the
>browser window indefinately, and if I close the browser window, the
>mod_python process is terminated, right?
In general this is not an issue. However it depends to some degree on
what your mod_python program is doing. Here is a really, REALLY feeble
example w/publisher:
def ping(req, target_ip):
import commands
output = commands.getoutput('ping -c 10000 %s' % target_ip)
return output
Even if the user closes the window or hits 'stop' the process stays
until the ping finishes. In this example this is merely annoying (10k
pings takes almost 3 hours) but if it had been 'fping -el %s' instead
you would be in real trouble (since it would never exit).
Restarting apache clears such zombie processes.
btw, 'ping' as written above is horrible. If a code review turned
_that_ up on production someone would be fired, along with whoever
hired them, whoever ate lunch with them and anyone that waves goodbye.
More information about the Python-list
mailing list