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.

Author vstinner
Recipients flox, gregory.p.smith, martin.panter, meishao, neologix, pitrou, tholzer, vstinner
Date 2015-04-06.23:53:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:

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.)
Date User Action Args
2015-04-06 23:53:42vstinnersetrecipients: + vstinner, gregory.p.smith, pitrou, flox, tholzer, neologix, martin.panter, meishao
2015-04-06 23:53:42vstinnersetmessageid: <>
2015-04-06 23:53:42vstinnerlinkissue20611 messages
2015-04-06 23:53:42vstinnercreate