[mod_python] browser connection state

Miguel Marques miguel at yorku.ca
Fri Feb 23 08:40:13 EST 2001


Greetings...
On Thu, 22 Feb 2001 22:41:45 -0800, "Ensim-Newsgroups.Mailing-Lists.Mod_Python-List" <ensim.ml.mod_python at ensim.com> wrote:
> is there a way in mod python to check whether the browser connection has
> been aborted?  ie, given a single request, before writing each chunk of
> response data to the browser, can we check whether the browser user pressed
> the stop button (or pressed escape).
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python

If the browser goes away for any reason (stop, reload, etc) and you
try to write to the client, you get an IOError exception which you can
catch.  

I usually have req.write(" ")'s just before database writes and the
such to try and cause this exception to be thrown so I can clean up
and exit and not do anything.

						      Miguel

C. Miguel Marques, York University, Computing & Network Services
e-mail: miguel at yorku.ca, voice: (416)736-2100x22684, fax: (416)736-5830



More information about the Mod_python mailing list