Author hniksic
Recipients asvetlov, docs@python, hniksic, yselivanov
Date 2019-10-09.17:14:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1570641279.2.0.929881138502.issue38423@roundup.psfhosted.org>
In-reply-to
Content
The docs of SelectorEventLoop and ProactorEventLoop contain examples that call asyncio.set_event_loop:

      selector = selectors.SelectSelector()
      loop = asyncio.SelectorEventLoop(selector)
      asyncio.set_event_loop(loop)

But this won't have any effect on code that uses asyncio.run(), because asyncio.run() creates a fresh event loop. Since asyncio.run() is the recommended way to execute async code and is used consistently throughout the documentation, this might be confusing to someone who tries to e.g. use the proactor loop on Windows.

I propose the following:

* add a disclaimer that instantiating the event loop won't affect calls to asyncio.run(), and that loop.run_until_complete() must be used; and

* link to asyncio.set_event_loop_policy(), which does work with asyncio.run(), but doesn't allow fine-tuning the details, such as which selector to use for the SelectorEventLoop.
History
Date User Action Args
2019-10-09 17:14:39hniksicsetrecipients: + hniksic, asvetlov, docs@python, yselivanov
2019-10-09 17:14:39hniksicsetmessageid: <1570641279.2.0.929881138502.issue38423@roundup.psfhosted.org>
2019-10-09 17:14:39hniksiclinkissue38423 messages
2019-10-09 17:14:39hniksiccreate