set_blocking_signal_threshold equivalent for asyncio?

Hi, In tornado, there's a really nice feature called set_blocking_signal_threshold, which sets a signal that fires if a coroutine has been running for too long without returning control back to the main loop: https://www.tornadoweb.org/en/stable/ioloop.html?highlight=signal#tornado.io... In tornado this will then log the traceback of the coroutine in question. This has been a very valuable tool when a developer accidentally introduces code that blocks the event loop for way too long of a time. Is there an equivalent in asyncio? I have a sketch in my head of how to implement that, but wanted to see if it existed somewhere first. Thanks! -Yusuke

Asyncio's debug mode does this (and a few more things). Call `asyncio.get_event_loop().set_debug()` to enable it. https://docs.python.org/3/library/asyncio-dev.html#debug-mode -Ben On Fri, Feb 8, 2019 at 5:10 PM Yusuke Tsutsumi <yusuke@tsutsumi.io> wrote:
Hi,
In tornado, there's a really nice feature called set_blocking_signal_threshold, which sets a signal that fires if a coroutine has been running for too long without returning control back to the main loop:
https://www.tornadoweb.org/en/stable/ioloop.html?highlight=signal#tornado.io...
In tornado this will then log the traceback of the coroutine in question. This has been a very valuable tool when a developer accidentally introduces code that blocks the event loop for way too long of a time.
Is there an equivalent in asyncio? I have a sketch in my head of how to implement that, but wanted to see if it existed somewhere first.
Thanks! -Yusuke _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/

Great, thank you! I'll try it out, looks promising. On Fri, Feb 8, 2019 at 5:37 PM Ben Darnell <ben@bendarnell.com> wrote:
Asyncio's debug mode does this (and a few more things). Call `asyncio.get_event_loop().set_debug()` to enable it.
https://docs.python.org/3/library/asyncio-dev.html#debug-mode
-Ben
On Fri, Feb 8, 2019 at 5:10 PM Yusuke Tsutsumi <yusuke@tsutsumi.io> wrote:
Hi,
In tornado, there's a really nice feature called set_blocking_signal_threshold, which sets a signal that fires if a coroutine has been running for too long without returning control back to the main loop:
https://www.tornadoweb.org/en/stable/ioloop.html?highlight=signal#tornado.io...
In tornado this will then log the traceback of the coroutine in question. This has been a very valuable tool when a developer accidentally introduces code that blocks the event loop for way too long of a time.
Is there an equivalent in asyncio? I have a sketch in my head of how to implement that, but wanted to see if it existed somewhere first.
Thanks! -Yusuke _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/

hi, followup question: Is there an impact to performance when using debug mode? On Tue, Feb 12, 2019 at 11:08 PM Yusuke Tsutsumi <yusuke@tsutsumi.io> wrote:
Great, thank you! I'll try it out, looks promising.
On Fri, Feb 8, 2019 at 5:37 PM Ben Darnell <ben@bendarnell.com> wrote:
Asyncio's debug mode does this (and a few more things). Call `asyncio.get_event_loop().set_debug()` to enable it.
https://docs.python.org/3/library/asyncio-dev.html#debug-mode
-Ben
On Fri, Feb 8, 2019 at 5:10 PM Yusuke Tsutsumi <yusuke@tsutsumi.io> wrote:
Hi,
In tornado, there's a really nice feature called set_blocking_signal_threshold, which sets a signal that fires if a coroutine has been running for too long without returning control back to the main loop:
https://www.tornadoweb.org/en/stable/ioloop.html?highlight=signal#tornado.io...
In tornado this will then log the traceback of the coroutine in question. This has been a very valuable tool when a developer accidentally introduces code that blocks the event loop for way too long of a time.
Is there an equivalent in asyncio? I have a sketch in my head of how to implement that, but wanted to see if it existed somewhere first.
Thanks! -Yusuke _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/
participants (2)
-
Ben Darnell
-
Yusuke Tsutsumi