STINNER Victor added the comment:

This issue was fixed in Python 3.5 as part of the PEP 475: see issue #23618 
which modified socket.socket.connect() to handle EINTR. It's not as simple as 
retrying connect() in a loop. You must respect the socket timeout (it's better 
to have a monotonic clock here, it's now always the case in Python 3.5). When 
connect() returns EINTR, the connection runs asynchronously, you have to call 
select() to wait until the connection completes or fails. Then you have to call 
getsockopt() to get the socket error code.

In Python 3.5, socket.socket.connect() still raises InterruptedError if the 
socket is non-blocking:
https://docs.python.org/dev/library/socket.html#socket.socket.connect

issue20611-connect-eintr-gps01.diff calls again connect() if connect() failed 
with EINTR. According to the issue #23618, it might work on some platforms, but 
it's not portable.

For Python 2.7 and 3.4, instead of fixing socket.socket.connect(), which 
requires complex code, we may only workaround the issue in create_connection(). 
If connect() raises OSError(EINTR), drop the socket and retry with a fresh 
connection in a loop until the connection completes or raises a different 
exception. (And do that for each address.)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue20611>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to