def _exception_handler(self, loop, context):
exc = context.get('exception')
if exc:
loop.stop()
if not isinstance(exc, urwid.ExitMainLoop):
self._exc_info = exc
else:
loop.default_exception_handler(context)