[issue31950] Default event loop policy doc lacks precision

Antoine Pitrou report at bugs.python.org
Sun Nov 5 13:16:09 EST 2017


New submission from Antoine Pitrou <pitrou at free.fr>:

The doc for the default event loop policy states that """the default policy defines context as the current thread, and manages an event loop per thread that interacts with asyncio""".  What it doesn't mention, though, is that you get a RuntimeError if you call get_event_loop() in a non-main thread -- you first have to call set_event_loop(new_event_loop()) in that thread.  This wasn't expected by me.

As a side note, customizing the event loop policy isn't trivial either: it seems it's best to subclass DefaultEventLoopPolicy and make adjustments by overriding the API methods.  Writing your own wouldn't work, as e.g. the Unix default policy has custom initialization code for child watchers.

----------
assignee: docs at python
components: Documentation, asyncio
messages: 305607
nosy: docs at python, giampaolo.rodola, gvanrossum, haypo, pitrou, yselivanov
priority: normal
severity: normal
status: open
title: Default event loop policy doc lacks precision
type: behavior
versions: Python 3.6, Python 3.7

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


More information about the Python-bugs-list mailing list