[issue37172] Odd error awating a Future

Andrew Svetlov report at bugs.python.org
Thu Jun 6 07:10:52 EDT 2019


Andrew Svetlov <andrew.svetlov at gmail.com> added the comment:

Global future objects (and global asyncio objects in general) don't work with asyncio.run(). The lifecycle of these objects should be closer than loop but asyncio.run() creates a loop during execution.

I think this is a good design, we have a plan to deprecate and eventually drop all old-times mess that allows confusions.

All three of your problems are because you use a global future which is implicitly attached to the different loop.

Also I'd like to note that futures are low-level API, which is very delicate and error-prone. Futures are crucial for libraries building (e.g. aiohttp uses them a lot) but working with futures in application code is an explicit sign of bad design.

----------

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


More information about the Python-bugs-list mailing list