Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions Lib/asyncio/proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,6 @@ def sock_connect(self, sock, address):
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()
Expand All @@ -461,7 +458,7 @@ def _close_self_pipe(self):

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
Expand Down
5 changes: 1 addition & 4 deletions Lib/asyncio/selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,6 @@ def close(self):
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()
Expand All @@ -109,7 +106,7 @@ def _close_self_pipe(self):

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
Expand Down
5 changes: 1 addition & 4 deletions Lib/asyncio/unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,6 @@ def __init__(self, selector=None):
super().__init__(selector)
self._signal_handlers = {}

def _socketpair(self):
return socket.socketpair()

def close(self):
super().close()
for sig in list(self._signal_handlers):
Expand Down Expand Up @@ -677,7 +674,7 @@ def _start(self, args, shell, stdin, stdout, stderr, bufsize, **kwargs):
# 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
Expand Down
6 changes: 0 additions & 6 deletions Lib/asyncio/windows_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,6 @@ def close(self):
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."""
Expand All @@ -308,9 +305,6 @@ def __init__(self, proactor=None):
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)
Expand Down
18 changes: 4 additions & 14 deletions Lib/test/test_asyncio/test_proactor_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,15 +444,13 @@ def setUp(self):

self.ssock, self.csock = mock.Mock(), mock.Mock()

class EventLoop(BaseProactorEventLoop):
def _socketpair(s):
return (self.ssock, self.csock)

self.loop = EventLoop(self.proactor)
with mock.patch('asyncio.proactor_events.socket.socketpair',
return_value=(self.ssock, self.csock)):
self.loop = BaseProactorEventLoop(self.proactor)
self.set_event_loop(self.loop)

@mock.patch.object(BaseProactorEventLoop, 'call_soon')
@mock.patch.object(BaseProactorEventLoop, '_socketpair')
@mock.patch('asyncio.proactor_events.socket.socketpair')
def test_ctor(self, socketpair, call_soon):
ssock, csock = socketpair.return_value = (
mock.Mock(), mock.Mock())
Expand Down Expand Up @@ -506,14 +504,6 @@ def test_sock_accept(self):
self.loop.sock_accept(self.sock)
self.proactor.accept.assert_called_with(self.sock)

def test_socketpair(self):
class EventLoop(BaseProactorEventLoop):
# override the destructor to not log a ResourceWarning
def __del__(self):
pass
self.assertRaises(
NotImplementedError, EventLoop, self.proactor)

def test_make_socket_transport(self):
tr = self.loop._make_socket_transport(self.sock, asyncio.Protocol())
self.assertIsInstance(tr, _ProactorSocketTransport)
Expand Down
3 changes: 0 additions & 3 deletions Lib/test/test_asyncio/test_selector_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,6 @@ def test_close_no_selector(self):
self.loop.close()
self.assertIsNone(self.loop._selector)

def test_socketpair(self):
self.assertRaises(NotImplementedError, self.loop._socketpair)

def test_read_from_self_tryagain(self):
self.loop._ssock.recv.side_effect = BlockingIOError
self.assertIsNone(self.loop._read_from_self())
Expand Down
3 changes: 2 additions & 1 deletion Lib/test/test_asyncio/test_windows_events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import socket
import sys
import unittest
from unittest import mock
Expand Down Expand Up @@ -36,7 +37,7 @@ def setUp(self):
self.set_event_loop(self.loop)

def test_close(self):
a, b = self.loop._socketpair()
a, b = socket.socketpair()
trans = self.loop._make_socket_transport(a, asyncio.Protocol())
f = asyncio.ensure_future(self.loop.sock_recv(b, 100))
trans.close()
Expand Down