def _handle_exception( self, loop: AbstractEventLoop, context: Dict[str, Any] ) -> None: """ Handler for event loop exceptions. This will print the exception, using run_in_terminal. """ # For Python 2: we have to get traceback at this point, because # we're still in the 'except:' block of the event loop where the # traceback is still available. Moving this code in the # 'print_exception' coroutine will loose the exception. tb = get_traceback_from_context(context) formatted_tb = "".join(format_tb(tb)) async def in_term() -> None: async with in_terminal(): # Print output. Similar to 'loop.default_exception_handler', # but don't use logger. (This works better on Python 2.) print("\nUnhandled exception in event loop:") print(formatted_tb) print("Exception %s" % (context.get("exception"),)) await _do_wait_for_enter("Press ENTER to continue...") ensure_future(in_term())
def handle_exception(loop, context: Dict[str, Any]) -> None: " Print the exception, using run_in_terminal. " # For Python 2: we have to get traceback at this point, because # we're still in the 'except:' block of the event loop where the # traceback is still available. Moving this code in the # 'print_exception' coroutine will loose the exception. tb = get_traceback_from_context(context) formatted_tb = ''.join(format_tb(tb)) async def in_term() -> None: async with in_terminal(): # Print output. Similar to 'loop.default_exception_handler', # but don't use logger. (This works better on Python 2.) print('\nUnhandled exception in event loop:') print(formatted_tb) print('Exception %s' % (context.get('exception'), )) await _do_wait_for_enter('Press ENTER to continue...') ensure_future(in_term())