[issue26969] ascynio should provide a policy to address pass-loop-everywhere problem

Yury Selivanov report at bugs.python.org
Fri May 6 16:18:10 EDT 2016


Yury Selivanov added the comment:

> Thread may have multiple event loops, but only one, explicitly associated, is default. And it's not necessary one which is currently running.

Ah, I got it.  You know what, this actually is starting to make sense.

Guido, what do you think about this?  Essentially, (Ilya, feel free to correct me if I'm wrong), we can implement the following:

1. Add a new thread-local storage, say "_running_loop"

2. Add another method "asyncio.get_running_loop()"

3. Update some places in asyncio where we currently use "get_event_loop()", such as Future constructor, Task.current_task, etc.

This might actually solve an awkwardness of get_event_loop(), which when called, instantiates an event loop if it doesn't find one, which makes it difficult to know if an event loop was running before the call.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26969>
_______________________________________


More information about the Python-bugs-list mailing list