self._selector = None
def sock_recv(self, sock, n):
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
return self._proactor.recv(sock, n)
def sock_sendall(self, sock, data):
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
return self._proactor.send(sock, data)
def sock_connect(self, sock, address):
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
try:
base_events._check_resolved_address(sock, address)
except ValueError as err:
return self._proactor.connect(sock, address)
def sock_accept(self, sock):
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
return self._proactor.accept(sock)
def _socketpair(self):
This method is a coroutine.
"""
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
fut = futures.Future(loop=self)
self._sock_recv(fut, False, sock, n)
return fut
This method is a coroutine.
"""
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
fut = futures.Future(loop=self)
if data:
self._sock_sendall(fut, False, sock, data)
This method is a coroutine.
"""
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
fut = futures.Future(loop=self)
try:
base_events._check_resolved_address(sock, address)
This method is a coroutine.
"""
+ if self.get_debug() and sock.gettimeout() != 0:
+ raise ValueError("the socket must be non-blocking")
fut = futures.Future(loop=self)
self._sock_accept(fut, False, sock)
return fut
self.assertEqual(read, data)
def _basetest_sock_client_ops(self, httpd, sock):
+ # in debug mode, socket operations must fail
+ # if the socket is not in blocking mode
+ self.loop.set_debug(True)
+ sock.setblocking(True)
+ with self.assertRaises(ValueError):
+ self.loop.run_until_complete(
+ self.loop.sock_connect(sock, httpd.address))
+ with self.assertRaises(ValueError):
+ self.loop.run_until_complete(
+ self.loop.sock_sendall(sock, b'GET / HTTP/1.0\r\n\r\n'))
+ with self.assertRaises(ValueError):
+ self.loop.run_until_complete(
+ self.loop.sock_recv(sock, 1024))
+ with self.assertRaises(ValueError):
+ self.loop.run_until_complete(
+ self.loop.sock_accept(sock))
+
+ # test in non-blocking mode
sock.setblocking(False)
self.loop.run_until_complete(
self.loop.sock_connect(sock, httpd.address))