Gracefully handle callback crashes.

This commit is contained in:
David Wilson 2016-08-14 19:40:42 +01:00
parent 2703e444ef
commit 54b0a0aed7
1 changed files with 6 additions and 2 deletions

View File

@ -329,7 +329,7 @@ class Stream(BasicStream):
return True
def _invoke(self, handle, data):
IOLOG.debug('%r._invoke(): handle=%r; data=%r', self, handle, data)
IOLOG.debug('%r._invoke(%r, %r)', self, handle, data)
try:
persist, fn = self._context._handle_map[handle]
except KeyError:
@ -337,7 +337,11 @@ class Stream(BasicStream):
if not persist:
del self._context._handle_map[handle]
fn(data)
try:
fn(data)
except Exception:
LOG.debug('%r._invoke(%r, %r): %r crashed', self, handle, data, fn)
def on_transmit(self):
"""Transmit buffered messages."""