summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-04-07 21:36:27 +0200
committerVictor Stinner <victor.stinner@gmail.com>2015-04-07 21:36:27 +0200
commitb26e6ae21989993e48168f7c5a5db57d496114d2 (patch)
tree179ce6af89b182a4aba3d59cbeadb74a9055d75a
parent15a569d29b6ea60ebf9716117702e22d87ae638d (diff)
downloadtrollius-git-b26e6ae21989993e48168f7c5a5db57d496114d2.tar.gz
Python issue #23879: SelectorEventLoop.sock_connect() must not call connect()
again if the first call to connect() raises an InterruptedError. When the C function connect() fails with EINTR, the connection runs in background. We have to wait until the socket becomes writable to be notified when the connection succeed or fails.
-rw-r--r--asyncio/selector_events.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/asyncio/selector_events.py b/asyncio/selector_events.py
index 68e9415..7c5b9b5 100644
--- a/asyncio/selector_events.py
+++ b/asyncio/selector_events.py
@@ -408,14 +408,12 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
def _sock_connect(self, fut, sock, address):
fd = sock.fileno()
try:
- while True:
- try:
- sock.connect(address)
- except InterruptedError:
- continue
- else:
- break
- except BlockingIOError:
+ sock.connect(address)
+ except (BlockingIOError, InterruptedError):
+ # Issue #23618: When the C function connect() fails with EINTR, the
+ # connection runs in background. We have to wait until the socket
+ # becomes writable to be notified when the connection succeed or
+ # fails.
fut.add_done_callback(functools.partial(self._sock_connect_done,
fd))
self.add_writer(fd, self._sock_connect_cb, fut, sock, address)