[issue777588] asyncore/Windows: select() doesn't report errors for a non-blocking connect()

STINNER Victor report at bugs.python.org
Sat Jun 28 00:40:49 CEST 2014


STINNER Victor added the comment:

"Workaround: (...)
e = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)"

Oh, it looks like the issue was already fixed 4 years ago:
---
changeset:   63720:ba7353147507
branch:      3.1
parent:      63716:915b028b954d
user:        Giampaolo Rodolà <g.rodola at gmail.com>
date:        Wed Aug 04 09:04:53 2010 +0000
files:       Lib/asyncore.py Misc/ACKS Misc/NEWS
description:
Merged revisions 83705 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r83705 | giampaolo.rodola | 2010-08-04 11:02:27 +0200 (mer, 04 ago 2010) | 1 line

  fix issue #2944: asyncore doesn't handle connection refused correctly (patch by Alexander Shigin). Merged from 2.7 branch.
........


diff -r 915b028b954d -r ba7353147507 Lib/asyncore.py
--- a/Lib/asyncore.py   Wed Aug 04 04:53:07 2010 +0000
+++ b/Lib/asyncore.py   Wed Aug 04 09:04:53 2010 +0000
@@ -426,8 +426,11 @@ class dispatcher:
             self.handle_read()
 
     def handle_connect_event(self):
+        err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
+        if err != 0:
+            raise socket.error(err, _strerror(err))
+        self.handle_connect()
         self.connected = True
-        self.handle_connect()
 
     def handle_write_event(self):
         if self.accepting:
...
---

----------
resolution:  -> fixed
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue777588>
_______________________________________


More information about the Python-bugs-list mailing list