homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: asyncore should handle ECONNRESET in send
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: josiahcarlson Nosy List: efge, josiahcarlson
Priority: normal Keywords:

Created on 2004年11月10日 16:27 by efge, last changed 2022年04月11日 14:56 by admin. This issue is now closed.

Messages (3)
msg23084 - (view) Author: Florent Guillaume (efge) Date: 2004年11月10日 16:27
asyncore.dispatcher.send doesn't handle ECONNRESET,
whereas recv correctly does.
When such an error occurs, Zope displays for instance:
ERROR(200) ZServer uncaptured python exception, closing
channel <ZServer.HTTPServer.zhttp_channel connected
x.x.x.x:33054 at 0x4608ac2c channel#: 50679 requests:>
(socket.error:(104, 'Connection reset by peer')
[/usr/local/lib/python2.3/asynchat.py|initiate_send|218]
[/usr/local/zope/2.7.2/lib/python/ZServer/medusa/http_server.py|send|417]
[/usr/local/lib/python2.3/asyncore.py|send|337])
zhttp_channel is just a subclass of http_channel.
The exception is raised by asyncore itself when it
receives the unhandled error.
A proposed fix would be to do the same kind of handling
than is done in recv, but I don't know enough about
asyncore to know if it's correct
msg23085 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2007年01月07日 05:49
It would seem to me that a connection where sending raises ECONNRESET, ENOTCONN, or ESHUTDOWN, should be closed, as is the case in recv.
However, generally send is usually called before recv, so if we close the connection in send, then recv won't get called. In basically all cases, we want recv() to be called so that we get data from the buffers if possible. Usually if there is data in the buffers, an exception won't be raised, so we wouldn't close the connection until the next pass.
If we make a change at all, I would change send() to:
 def send(self, data):
 try:
 result = self.socket.send(data)
 return result
 except socket.error, why:
 if why[0] == EWOULDBLOCK:
 return 0
 elif why[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN]:
 return 0
 else:
 raise
I have not yet tested the behavior in Python 2.5 yet, as the test cases for Python 2.5 asyncore are basically nonexistent. If we added portions of the test cases provided in patch #909005, we could more easily test these kinds of things.
msg69214 - (view) Author: Josiah Carlson (josiahcarlson) * (Python triager) Date: 2008年07月03日 17:58
We are actually closing the socket before returning in the latest
version of asyncore. Closing as fixed.
History
Date User Action Args
2022年04月11日 14:56:08adminsetgithub: 41161
2008年07月03日 17:58:03josiahcarlsonsetstatus: open -> closed
resolution: fixed
messages: + msg69214
2004年11月10日 16:27:32efgecreate

AltStyle によって変換されたページ (->オリジナル) /