[issue38599] Deprecate creation of asyncio object when the loop is not running

Berry Schoenmakers report at bugs.python.org
Mon Oct 28 14:54:43 EDT 2019


Berry Schoenmakers <l.a.m.schoenmakers at tue.nl> added the comment:

The current implementation of asyncio.run() is focused quite a bit on one-shot use. After the call returns, the default event loop is even gone: calling asyncio.get_event_loop() gives "RuntimeError: There is no current event loop in thread 'MainThread'."

It would be nice if asyncio.run() uses the default loop if it's available (and not running), and that the default loop remains intact after the call returns. 

This way multiple calls to asyncio.run() that all use the default loop are supported, maybe using an asyncio.Queue (or whatever) across these calls---attaching everything to the same (default) loop.

I find this very useful, for instance when writing unit tests.

----------
nosy: +lschoe

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38599>
_______________________________________


More information about the Python-bugs-list mailing list