summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/proactor_events.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-08-25 21:20:52 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-08-25 21:20:52 (GMT)
commitb261475a48d905f160bc1f499e90b995b0d0b6c0 (patch)
tree1151160908141088d3fa02db4028006f67603d07 /Lib/asyncio/proactor_events.py
parentd71dcbb043578c0abe770a2f37fac36e1a402821 (diff)
downloadcpython-b261475a48d905f160bc1f499e90b995b0d0b6c0.zip
cpython-b261475a48d905f160bc1f499e90b995b0d0b6c0.tar.gz
cpython-b261475a48d905f160bc1f499e90b995b0d0b6c0.tar.bz2
asyncio: sync with Tulip
* PipeServer.close() now cancels the "accept pipe" future which cancels the overlapped operation. * Fix _SelectorTransport.__repr__() if the transport was closed * Fix debug log in BaseEventLoop.create_connection(): get the socket object from the transport because SSL transport closes the old socket and creates a new SSL socket object. Remove also the _SelectorSslTransport._rawsock attribute: it contained the closed socket (not very useful) and it was not used. * Issue #22063: socket operations (sock_recv, sock_sendall, sock_connect, sock_accept) of the proactor event loop don't raise an exception in debug mode if the socket are in blocking mode. Overlapped operations also work on blocking sockets. * Fix unit tests in debug mode: mock a non-blocking socket for socket operations which now raise an exception if the socket is blocking. * _fatal_error() method of _UnixReadPipeTransport and _UnixWritePipeTransport now log all exceptions in debug mode * Don't log expected errors in unit tests * Tulip issue 200: _WaitHandleFuture._unregister_wait() now catchs and logs exceptions. * Tulip issue 200: Log errors in debug mode instead of simply ignoring them.
Diffstat (limited to 'Lib/asyncio/proactor_events.py')
-rw-r--r--Lib/asyncio/proactor_events.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index 751155b..0ad0656 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -172,6 +172,9 @@ class _ProactorReadPipeTransport(_ProactorBasePipeTransport,
except ConnectionAbortedError as exc:
if not self._closing:
self._fatal_error(exc, 'Fatal read error on pipe transport')
+ elif self._loop.get_debug():
+ logger.debug("Read error on pipe transport while closing",
+ exc_info=True)
except ConnectionResetError as exc:
self._force_close(exc)
except OSError as exc:
@@ -324,12 +327,16 @@ class _ProactorSocketTransport(_ProactorReadPipeTransport,
try:
self._extra['sockname'] = sock.getsockname()
except (socket.error, AttributeError):
- pass
+ if self._loop.get_debug():
+ logger.warning("getsockname() failed on %r",
+ sock, exc_info=True)
if 'peername' not in self._extra:
try:
self._extra['peername'] = sock.getpeername()
except (socket.error, AttributeError):
- pass
+ if self._loop.get_debug():
+ logger.warning("getpeername() failed on %r",
+ sock, exc_info=True)
def can_write_eof(self):
return True
@@ -385,18 +392,12 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
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:
@@ -407,8 +408,6 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
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):
@@ -470,11 +469,14 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
except OSError as exc:
if sock.fileno() != -1:
self.call_exception_handler({
- 'message': 'Accept failed',
+ 'message': 'Accept failed on a socket',
'exception': exc,
'socket': sock,
})
sock.close()
+ elif self._debug:
+ logger.debug("Accept failed on socket %r",
+ sock, exc_info=True)
except futures.CancelledError:
sock.close()
else: