On Tue, Apr 24, 2018 at 9:54 PM, Nathaniel Smith <n...@pobox.com> wrote: > > The simplest solution would be to use asyncio's native signal handler > support instead of the signal module: > https://docs.python.org/3/library/asyncio-eventloop.html#unix-signals >
Ahh, wow, I don't know how I missed this. I've been obsessing over coroutines and event loops for hours, now I realize that I misunderstood the voodoo in the signal module. Thank you for pointing me in this direction! Alternatively, you can define a handler using signal.signal, and then > arrange to re-enter the asyncio main loop yourself before calling > Task.cancel. I believe that the only guaranteed-to-be-safe way to do > this is: This is also an interesting approach that I will experiment with. I guess this solves problem #1 (works on Windows) but not #2 (task stuck in loop), right? (The latter is a feature of all cooperative multitasking systems, yeah?) Great blog post today! I really enjoy your writing style and Trio is really exciting. Cheers, Mark
_______________________________________________ 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/