New submission from Antoine Pitrou <pit...@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@python
components: Documentation, asyncio
messages: 305607
nosy: docs@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue31950>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to