[issue2944] asyncore doesn't handle connection refused correctly
Giampaolo Rodola'
report at bugs.python.org
Sat May 24 20:26:12 CEST 2008
Giampaolo Rodola' <billiejoex at users.sourceforge.net> added the comment:
By trying your script on Linux and Windows I notice different behaviors.
On Windows handle_expt is always called.
On Linux, no matter if using select or poll, handle_accept is called,
then an exception is thrown at the time the data is going to be sent:
Traceback (most recent call last):
File "index.py", line 34, in <module>
test()
File "index.py", line 31, in test
asyncore.loop(use_poll=1)
File "/usr/lib/python2.5/asyncore.py", line 205, in loop
poll_fun(timeout, map)
File "/usr/lib/python2.5/asyncore.py", line 190, in poll2
readwrite(obj, flags)
File "/usr/lib/python2.5/asyncore.py", line 101, in readwrite
obj.handle_error()
File "/usr/lib/python2.5/asyncore.py", line 93, in readwrite
obj.handle_read_event()
File "/usr/lib/python2.5/asyncore.py", line 400, in handle_read_event
self.handle_connect()
File "index.py", line 17, in handle_connect
self.send("hello world")
File "/usr/lib/python2.5/asyncore.py", line 481, in send
self.initiate_send()
File "/usr/lib/python2.5/asyncore.py", line 468, in initiate_send
num_sent = dispatcher.send(self, self.out_buffer[:512])
File "/usr/lib/python2.5/asyncore.py", line 345, in send
result = self.socket.send(data)
socket.error: (111, 'Connection refused')
In my opinion both behaviors are wrong since neither handle_expt nor
handle_connect should be called in case of a "connection refused" event.
Especially handle_connect should not be called at all since no
connection takes place.
The correct behavior here must be identifying when such event occurs,
raise the proper exception (ECONNREFUSED) and let it propagate until
handle_error which will take care of it.
__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2944>
__________________________________
More information about the Python-bugs-list
mailing list