summaryrefslogtreecommitdiffstats
path: root/Lib/asyncio/unix_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/unix_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/unix_events.py')
-rw-r--r--Lib/asyncio/unix_events.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/Lib/asyncio/unix_events.py b/Lib/asyncio/unix_events.py
index e0d7507..9a40c04 100644
--- a/Lib/asyncio/unix_events.py
+++ b/Lib/asyncio/unix_events.py
@@ -65,7 +65,7 @@ class _UnixSelectorEventLoop(selector_events.BaseSelectorEventLoop):
except ValueError as exc:
raise RuntimeError(str(exc))
- handle = events.Handle(callback, args)
+ handle = events.Handle(callback, args, self)
self._signal_handlers[sig] = handle
try:
@@ -294,7 +294,12 @@ class _UnixReadPipeTransport(transports.ReadTransport):
def _fatal_error(self, exc):
# should be called by exception handler only
if not (isinstance(exc, OSError) and exc.errno == errno.EIO):
- logger.exception('Fatal error for %s', self)
+ self._loop.call_exception_handler({
+ 'message': 'Fatal transport error',
+ 'exception': exc,
+ 'transport': self,
+ 'protocol': self._protocol,
+ })
self._close(exc)
def _close(self, exc):
@@ -441,7 +446,12 @@ class _UnixWritePipeTransport(selector_events._FlowControlMixin,
def _fatal_error(self, exc):
# should be called by exception handler only
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._close(exc)
def _close(self, exc=None):
@@ -582,8 +592,14 @@ class BaseChildWatcher(AbstractChildWatcher):
def _sig_chld(self):
try:
self._do_waitpid_all()
- except Exception:
- logger.exception('Unknown exception in SIGCHLD handler')
+ except Exception as exc:
+ # self._loop should always be available here
+ # as '_sig_chld' is added as a signal handler
+ # in 'attach_loop'
+ self._loop.call_exception_handler({
+ 'message': 'Unknown exception in SIGCHLD handler',
+ 'exception': exc,
+ })
def _compute_returncode(self, status):
if os.WIFSIGNALED(status):