mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
Issue #27040: Add loop.get_exception_handler method
This commit is contained in:
parent
7bf36dace8
commit
7ed7ce6ee7
4 changed files with 12 additions and 0 deletions
|
@ -1078,6 +1078,11 @@ class BaseEventLoop(events.AbstractEventLoop):
|
||||||
logger.info('%s: %r' % (debug_log, transport))
|
logger.info('%s: %r' % (debug_log, transport))
|
||||||
return transport, protocol
|
return transport, protocol
|
||||||
|
|
||||||
|
def get_exception_handler(self):
|
||||||
|
"""Return an exception handler, or None if the default one is in use.
|
||||||
|
"""
|
||||||
|
return self._exception_handler
|
||||||
|
|
||||||
def set_exception_handler(self, handler):
|
def set_exception_handler(self, handler):
|
||||||
"""Set handler as the new event loop exception handler.
|
"""Set handler as the new event loop exception handler.
|
||||||
|
|
||||||
|
|
|
@ -484,6 +484,9 @@ class AbstractEventLoop:
|
||||||
|
|
||||||
# Error handlers.
|
# Error handlers.
|
||||||
|
|
||||||
|
def get_exception_handler(self):
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
def set_exception_handler(self, handler):
|
def set_exception_handler(self, handler):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
|
@ -658,8 +658,10 @@ class BaseEventLoopTests(test_utils.TestCase):
|
||||||
self.loop.set_debug(True)
|
self.loop.set_debug(True)
|
||||||
self.loop._process_events = mock.Mock()
|
self.loop._process_events = mock.Mock()
|
||||||
|
|
||||||
|
self.assertIsNone(self.loop.get_exception_handler())
|
||||||
mock_handler = mock.Mock()
|
mock_handler = mock.Mock()
|
||||||
self.loop.set_exception_handler(mock_handler)
|
self.loop.set_exception_handler(mock_handler)
|
||||||
|
self.assertIs(self.loop.get_exception_handler(), mock_handler)
|
||||||
handle = run_loop()
|
handle = run_loop()
|
||||||
mock_handler.assert_called_with(self.loop, {
|
mock_handler.assert_called_with(self.loop, {
|
||||||
'exception': MOCK_ANY,
|
'exception': MOCK_ANY,
|
||||||
|
|
|
@ -454,6 +454,8 @@ Library
|
||||||
- Issue #26848: Fix asyncio/subprocess.communicate() to handle empty input.
|
- Issue #26848: Fix asyncio/subprocess.communicate() to handle empty input.
|
||||||
Patch by Jack O'Connor.
|
Patch by Jack O'Connor.
|
||||||
|
|
||||||
|
- Issue #27040: Add loop.get_exception_handler method
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue