summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/proactor_events.py
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2014-02-18 23:02:19 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2014-02-18 23:02:19 (GMT)
commitff827f08ac9201f56b14cb19ccb9d511434c858b (patch)
tree75a1b4b19c5eb74fa2fbf43d8df438b7c42b6e4d /Lib/asyncio/proactor_events.py
parent065efc3072c244ba34ce521ba0edaa4168fa8953 (diff)
downloadcpython-ff827f08ac9201f56b14cb19ccb9d511434c858b.zip
cpython-ff827f08ac9201f56b14cb19ccb9d511434c858b.tar.gz
cpython-ff827f08ac9201f56b14cb19ccb9d511434c858b.tar.bz2
asyncio: New error handling API. Issue #20681.
Diffstat (limited to 'Lib/asyncio/proactor_events.py')
-rw-r--r--Lib/asyncio/proactor_events.py33
1 files changed, 26 insertions, 7 deletions
diff --git a/Lib/asyncio/proactor_events.py b/Lib/asyncio/proactor_events.py
index 5de4d3d..b2ac632 100644
--- a/Lib/asyncio/proactor_events.py
+++ b/Lib/asyncio/proactor_events.py
@@ -56,7 +56,12 @@ class _ProactorBasePipeTransport(transports.BaseTransport):
def _fatal_error(self, exc):
if not isinstance(exc, (BrokenPipeError, ConnectionResetError)):
- logger.exception('Fatal error for %s', self)
+ self._loop.call_exception_handler({
+ 'message': 'Fatal transport error',
+ 'exception': exc,
+ 'transport': self,
+ 'protocol': self._protocol,
+ })
self._force_close(exc)
def _force_close(self, exc):
@@ -103,8 +108,13 @@ class _ProactorBasePipeTransport(transports.BaseTransport):
self._protocol_paused = True
try:
self._protocol.pause_writing()
- except Exception:
- logger.exception('pause_writing() failed')
+ except Exception as exc:
+ self._loop.call_exception_handler({
+ 'message': 'protocol.pause_writing() failed',
+ 'exception': exc,
+ 'transport': self,
+ 'protocol': self._protocol,
+ })
def _maybe_resume_protocol(self):
if (self._protocol_paused and
@@ -112,8 +122,13 @@ class _ProactorBasePipeTransport(transports.BaseTransport):
self._protocol_paused = False
try:
self._protocol.resume_writing()
- except Exception:
- logger.exception('resume_writing() failed')
+ except Exception as exc:
+ self._loop.call_exception_handler({
+ 'message': 'protocol.resume_writing() failed',
+ 'exception': exc,
+ 'transport': self,
+ 'protocol': self._protocol,
+ })
def set_write_buffer_limits(self, high=None, low=None):
if high is None:
@@ -465,9 +480,13 @@ class BaseProactorEventLoop(base_events.BaseEventLoop):
conn, protocol,
extra={'peername': addr}, server=server)
f = self._proactor.accept(sock)
- except OSError:
+ except OSError as exc:
if sock.fileno() != -1:
- logger.exception('Accept failed')
+ self.call_exception_handler({
+ 'message': 'Accept failed',
+ 'exception': exc,
+ 'socket': sock,
+ })
sock.close()
except futures.CancelledError:
sock.close()