[Zope-dev] Handling of ECONNRESET socket error in asyncore.py
Chris McDonough
chrism@zope.com
Fri, 23 Aug 2002 17:17:07 -0400
AFAIK, there is no way to "kill" a thread. On top of that, there is
no way to know if a browser "stop" actually means "stop processing"
(for example in the case of a long-running method, a browser stop
might just mean "I went to another web page, I'll be back, continue
running").
This is handled in ASP by requiring the programmer to insert stuff
like:
if REQUEST.isConnectionClosed:
return
else:
continue processing.
This might be a reasonable thing to add.
- C
----- Original Message -----
From: "Oliver Bleutgen" <myzope@gmx.net>
To: <zope-dev@zope.org>
Sent: Friday, August 23, 2002 5:06 PM
Subject: [Zope-dev] Handling of ECONNRESET socket error in
asyncore.py
> It just thought about the fact that zope on linux seemingly does
ignore
> when the user presses of the stop on his browser.
> I.e., if you access a e.g. long running python(script) and press
"Stop"
> on the browser and you'll see the thread which runs the script is
still
> working. Extremely ugly IMO.
>
> Well, it also happens on win. I just looked at
asyncore.dispatcher, and
> there's the recv() method:
>
> def recv (self, buffer_size):
> try:
> ...
> except socket.error, why:
> # winsock sometimes throws ENOTCONN
> if why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN]:
> self.handle_close()
> return ''
> else:
> raise socket.error, why
>
> The browser closes the connection when the Stop button is pressed,
that
> means that the recieving end gets a RST, and that seems to throw a
> socket.error, with why[0] == ECONNRESET. Well, I know jack about
the
> python socket class, but a strategical placed "print" tells more
than a
> thousand words ;-).
>
> handle_close() doesn't also do much, just logs and closes the
> connection. So, the poor thread never does never find out about
the fact
> that all his work is for nothing, and happily continues.
>
> Can't this be fixed anyhow?
>
> cheers,
> oliver
>
>
>
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>