mod_python and open HTTP connection

C

Charles

Hello, I'm think about using mod_python for a project but I need to make
sure: Does mod_python time out after a minute ? (I hope not). 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?
Thanks,
 
G

grahamd

Charles said:
Hello, I'm think about using mod_python for a project but I need to make
sure: Does mod_python time out after a minute ? (I hope not).

Mod_python itself doesn't time out. If such a thing happened it
would be because of how Apache, some intermediate proxy or
the client is configured.
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?

If the mod_python handler is periodically writing data back to the
browser, at the point the socket connection from the client closes,
the attempt to write data back to the client by the mod_python
handler will result in an IOError exception being raised. Presuming
that your handler code doesn't catch this and ignore it, it should
cause the handler to abort.

Note though that it doesn't cause any process to be terminated as
that is not how Apache/mod_python work. It will cause just that
current request to be terminated. That thread of control can then
be reused to handle a subsequent request.

BTW, for tricky questions on mod_python you are better of using
the mod_python mailing list. Details on the mod_python web site.

Graham
 
K

Kane

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.
 
C

Charles

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.

Really? Wow... Gotta be carefull from now on...
 

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,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top