Antoine Pitrou <pit...@free.fr> added the comment: Ok, one issue is that connect_ex() isn't implemented for SSL sockets, so it defers to the normal implementation instead, which is wrong.
But your still is wrong too. connect_ex() returns an error, meaning the socket isn't connected and you must retry. Here is a working snippet using connect(): def connect(): try: s.connect(('people.csail.mit.edu', 443)) except socket.error as e: if e.errno != errno.EINPROGRESS: raise return False else: return True while not connect(): select.select([s], [s], []) while True: try: select.select([s], [s], []) s.do_handshake() break except ssl.SSLError as err: if err.args[0] == ssl.SSL_ERROR_WANT_READ: select.select([s], [], []) elif err.args[0] == ssl.SSL_ERROR_WANT_WRITE: select.select([], [s], []) else: raise ---------- nosy: +pitrou stage: -> needs patch title: Asynchronous ssl handshakes fails for asynchronously connected sockets. -> connect_ex() implementation missing for SSL sockets versions: +Python 2.7, Python 3.3 -Python 2.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11326> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com