[mod_python] browser connection state

Naris Siamwalla naris at ensim.com
Fri Feb 23 11:00:39 EST 2001


catching the IOError exception is fine, but can i assume for -*all*- IOError
exceptions thrown when i req.write was because of a stop/reload?  could an
IOError be thrown for other reasons (e.g. apache itself causing mod_python
to throw the IOError exception) ?  if there are no other reaons, then i
guess it's safe to write a try block that assumes so.

-----Original Message-----
From: Miguel Marques [mailto:miguel at yorku.ca]
Sent: Friday, February 23, 2001 5:40 AM
To: ensim.ml.mod_python at ensim.com
Cc: mod_python at modpython.org
Subject: Re: [mod_python] browser connection state


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
_______________________________________________
Mod_python mailing list
Mod_python at modpython.org
http://www.modpython.org/mailman/listinfo/mod_python



More information about the Mod_python mailing list