[issue19860] asyncio: Add context manager to BaseEventLoop?

Guido van Rossum report at bugs.python.org
Mon Dec 2 17:47:41 CET 2013


Guido van Rossum added the comment:

To create a new event loop, use set_event_loop(new_event_loop()).  You have to do that if you want an event loop in a thread; it's also handy in unit tests.  (However asyncio's own unit tests only call new_event_loop() and pass it around explicitly with loop=...; they set the default event loop to None with set_event_loop(None).)

Creating a second event loop (in the same thread) while you already have an event loop is fraught with problems -- while the second one is running any events associated with the first one won't fire.

(This API is not random -- it is intentionally restricted to allow certain platform event loops to be adapted.)

----------

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


More information about the Python-bugs-list mailing list