This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: asyncio: how to set a "Proactor event loop" policy? Issue with
Type: Stage: resolved
Components: asyncio Versions: Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, miss-islington, vstinner, yselivanov
Priority: normal Keywords: patch

Created on 2018-06-07 10:02 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 7487 merged yselivanov, 2018-06-07 16:39
PR 7508 merged miss-islington, 2018-06-08 00:45
Messages (5)
msg318919 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-07 10:02
asyncio documentation suggets to use:
import asyncio, sys

if sys.platform == 'win32':
    loop = asyncio.ProactorEventLoop()

But this code doesn't work with which creates a new event loop with the current policy, and the default policy on Windows is to use SelectorEventLoop.

I cannot find a "Proactor event loop policy" in asyncio, nor how to change the default policy to use Proactor event loop.

The workaround is to not use which has been added in Python 3.7.
msg318924 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2018-06-07 10:45
Ugly workaround:

policy = asyncio.get_event_loop_policy()
policy._loop_factory = asyncio.ProactorEventLoop

It uses a private attribute :-(
msg318929 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-06-07 13:43
Looks like we need a proactor policy class.
msg319002 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-08 00:44
New changeset 8f4042964d5b0ddf5cdf87862db962ba64e3f64a by Yury Selivanov in branch 'master':
bpo-33792: Add selector and proactor windows policies (GH-7487)
msg319004 - (view) Author: miss-islington (miss-islington) Date: 2018-06-08 01:31
New changeset 0738443a5b071a6bd2c18957a06cfe571a7314f2 by Miss Islington (bot) in branch '3.7':
bpo-33792: Add selector and proactor windows policies (GH-7487)
Date User Action Args
2022-04-11 14:59:01adminsetgithub: 77973
2018-06-08 03:43:15yselivanovsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-06-08 01:31:52miss-islingtonsetnosy: + miss-islington
messages: + msg319004
2018-06-08 00:45:10miss-islingtonsetpull_requests: + pull_request7136
2018-06-08 00:44:59yselivanovsetmessages: + msg319002
2018-06-07 16:39:11yselivanovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request7112
2018-06-07 13:43:06asvetlovsetmessages: + msg318929
2018-06-07 10:45:20vstinnersetmessages: + msg318924
2018-06-07 10:02:04vstinnercreate