[issue31950] Default event loop policy doc lacks precision
New submission from Antoine Pitrou <pitrou@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 <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
Guido van Rossum <guido@python.org> added the comment: Agreed that this needs more clarification. Is something stopping you from submitting a PR? Note that the thing about non-main-threads is mentioned in the docstring for BaseDefaultEventLoopPolicy. I agree that the best way to create a new policy is to study the existing code and subclass DefaultEventLoopPolicy. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
Change by Antoine Pitrou <pitrou@free.fr>: ---------- keywords: +patch pull_requests: +4269 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: New changeset 4135c89395726024abddb7340a0c7a42c801f616 by Antoine Pitrou in branch 'master': bpo-31950: Improve event loop policy doc (#4306) https://github.com/python/cpython/commit/4135c89395726024abddb7340a0c7a42c80... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
Change by Roundup Robot <devnull@psf.upfronthosting.co.za>: ---------- pull_requests: +4270 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: New changeset e65617f65e203a2a6d3e3100d0d6fed0ffa0613d by Antoine Pitrou (Miss Islington (bot)) in branch '3.6': bpo-31950: Improve event loop policy doc (GH-4306) (#4307) https://github.com/python/cpython/commit/e65617f65e203a2a6d3e3100d0d6fed0ffa... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: Thank you Guido. This is fixed now. ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue31950> _______________________________________
participants (3)
-
Antoine Pitrou
-
Guido van Rossum
-
Roundup Robot