summaryrefslogtreecommitdiff
path: root/Lib/asyncio
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2017-11-28 11:15:26 +0100
committerGitHub <noreply@github.com>2017-11-28 11:15:26 +0100
commita10dc3efcbba8aa7cc7d1a017f8b22fc4fa8e87c (patch)
tree6ed634f185e7920ed25ae56e537e0202b675f7c9 /Lib/asyncio
parent92f9339a58a613a56683510499509d1b702921a8 (diff)
downloadcpython-git-a10dc3efcbba8aa7cc7d1a017f8b22fc4fa8e87c.tar.gz
asyncio: use directly socket.socketpair() (#4597)
Since Python 3.5, socket.socketpair() is also available on Windows, and so can be used directly, rather than using asyncio.windows_utils.socketpair().
Diffstat (limited to 'Lib/asyncio')
-rw-r--r--Lib/asyncio/proactor_events.py5
-rw-r--r--Lib/asyncio/selector_events.py5
-rw-r--r--Lib/asyncio/unix_events.py5
-rw-r--r--Lib/asyncio/windows_events.py6
4 files changed, 3 insertions, 18 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index e35d05b7bf..d7aa5ff301 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -446,9 +446,6 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
def sock_accept(self, sock):
return self._proactor.accept(sock)
- def _socketpair(self):
- raise NotImplementedError
-
def _close_self_pipe(self):
if self._self_reading_future is not None:
self._self_reading_future.cancel()
@@ -461,7 +458,7 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
def _make_self_pipe(self):
# A self-socket, really. :-)
- self._ssock, self._csock = self._socketpair()
+ self._ssock, self._csock = socket.socketpair()
self._ssock.setblocking(False)
self._csock.setblocking(False)
self._internal_fds += 1
diff --git a/Lib/asyncio/selector_events.py b/Lib/asyncio/selector_events.py
index 4baad48ce3..ef6f0ac458 100644
--- a/Lib/asyncio/selector_events.py
+++ b/Lib/asyncio/selector_events.py
@@ -96,9 +96,6 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
self._selector.close()
self._selector = None
- def _socketpair(self):
- raise NotImplementedError
-
def _close_self_pipe(self):
self._remove_reader(self._ssock.fileno())
self._ssock.close()
@@ -109,7 +106,7 @@ class BaseSelectorEventLoop(base_events.BaseEventLoop):
def _make_self_pipe(self):
# A self-socket, really. :-)
- self._ssock, self._csock = self._socketpair()
+ self._ssock, self._csock = socket.socketpair()
self._ssock.setblocking(False)
self._csock.setblocking(False)
self._internal_fds += 1
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index be98f334ce..94157f8c80 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -55,9 +55,6 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
super().__init__(selector)
self._signal_handlers = {}
- def _socketpair(self):
- return socket.socketpair()
-
def close(self):
super().close()
for sig in list(self._signal_handlers):
@@ -677,7 +674,7 @@ class _UnixSubprocessTransport(base_subprocess.BaseSubprocessTransport):
# socket (which we use in order to detect closing of the
# other end). Notably this is needed on AIX, and works
# just fine on other platforms.
- stdin, stdin_w = self._loop._socketpair()
+ stdin, stdin_w = socket.socketpair()
# Mark the write end of the stdin pipe as non-inheritable,
# needed by close_fds=False on Python 3.3 and older
diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index 6045ba029e..031e3f1874 100644
--- a/Lib/asyncio/windows_events.py
+++ b/Lib/asyncio/windows_events.py
@@ -296,9 +296,6 @@ class PipeServer(object):
class _WindowsSelectorEventLoop(selector_events.BaseSelectorEventLoop):
"""Windows version of selector event loop."""
- def _socketpair(self):
- return windows_utils.socketpair()
-
class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
"""Windows version of proactor event loop using IOCP."""
@@ -308,9 +305,6 @@ class ProactorEventLoop(proactor_events.BaseProactorEventLoop):
proactor = IocpProactor()
super().__init__(proactor)
- def _socketpair(self):
- return windows_utils.socketpair()
-
@coroutine
def create_pipe_connection(self, protocol_factory, address):
f = self._proactor.connect_pipe(address)