MCPcopy Index your code
hub / github.com/python/cpython / call_exception_handler

Method call_exception_handler

Lib/asyncio/base_events.py:1895–1967  ·  view source on GitHub ↗

Call the current event loop's exception handler. The context argument is a dict containing the following keys: - 'message': Error message; - 'exception' (optional): Exception object; - 'future' (optional): Future instance; - 'task' (optional): Task instance;

(self, context)

Source from the content-addressed store, hash-verified

1893 logger.error('\n'.join(log_lines), exc_info=exc_info)
1894
1895 def call_exception_handler(self, context):
1896 """Call the current event loop's exception handler.
1897
1898 The context argument is a dict containing the following keys:
1899
1900 - 'message': Error message;
1901 - 'exception' (optional): Exception object;
1902 - 'future' (optional): Future instance;
1903 - 'task' (optional): Task instance;
1904 - 'handle' (optional): Handle instance;
1905 - 'protocol' (optional): Protocol instance;
1906 - 'transport' (optional): Transport instance;
1907 - 'socket' (optional): Socket instance;
1908 - 'source_traceback' (optional): Traceback of the source;
1909 - 'handle_traceback' (optional): Traceback of the handle;
1910 - 'asyncgen' (optional): Asynchronous generator that caused
1911 the exception.
1912
1913 New keys maybe introduced in the future.
1914
1915 Note: do not overload this method in an event loop subclass.
1916 For custom exception handling, use the
1917 `set_exception_handler()` method.
1918 """
1919 if self._exception_handler is None:
1920 try:
1921 self.default_exception_handler(context)
1922 except (SystemExit, KeyboardInterrupt):
1923 raise
1924 except BaseException:
1925 # Second protection layer for unexpected errors
1926 # in the default implementation, as well as for subclassed
1927 # event loops with overloaded "default_exception_handler".
1928 logger.error('Exception in default exception handler',
1929 exc_info=True)
1930 else:
1931 try:
1932 ctx = None
1933 thing = context.get("task")
1934 if thing is None:
1935 # Even though Futures don't have a context,
1936 # Task is a subclass of Future,
1937 # and sometimes the 'future' key holds a Task.
1938 thing = context.get("future")
1939 if thing is None:
1940 # Handles also have a context.
1941 thing = context.get("handle")
1942 if thing is not None and hasattr(thing, "get_context"):
1943 ctx = thing.get_context()
1944 if ctx is not None and hasattr(ctx, "run"):
1945 ctx.run(self._exception_handler, self, context)
1946 else:
1947 self._exception_handler(self, context)
1948 except (SystemExit, KeyboardInterrupt):
1949 raise
1950 except BaseException as exc:
1951 # Exception in the user set custom exception handler.
1952 try:

Callers 1

shutdown_asyncgensMethod · 0.95

Calls 5

errorMethod · 0.45
getMethod · 0.45
get_contextMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected