Skip to content

Commit f3d6dc7

Browse files
committed
Add loop.get_exception_handler method (will be in asyncio in 3.5.2)
1 parent a6fe31d commit f3d6dc7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

tests/test_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ def handler(loop, exc):
269269

270270
self.loop.set_debug(True)
271271

272+
if hasattr(self.loop, 'get_exception_handler'):
273+
# Available since Python 3.5.2
274+
self.assertIsNone(self.loop.get_exception_handler())
272275
self.loop.set_exception_handler(handler)
276+
if hasattr(self.loop, 'get_exception_handler'):
277+
self.assertIs(self.loop.get_exception_handler(), handler)
273278
run_loop()
274279
self.assertEqual(len(errors), 1)
275280
self.assertRegex(errors[-1]['message'],

uvloop/loop.pyx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,11 @@ cdef class Loop:
15251525

15261526
aio_logger.error('\n'.join(log_lines), exc_info=exc_info)
15271527

1528+
def get_exception_handler(self):
1529+
"""Return an exception handler, or None if the default one is in use.
1530+
"""
1531+
return self._exception_handler
1532+
15281533
def set_exception_handler(self, handler):
15291534
"""Set handler as the new event loop exception handler.
15301535

0 commit comments

Comments
 (0)