Skip to content

Support ProactorEventLoop on Windows #1587

@ojarjur

Description

@ojarjur

Problem

Jupyter server forces the use of SelectorEventLoop on Windows.

This was initially done because Tornado 6.0.0 did not work with the (default) ProactorEventLoop on Windows.

However, Tornado has supported it since 6.1.0, and Jupyter server now requires a version of Tornado >= 6.2.0

Hence, Jupyter server can use the ProactorEventLoop without issue.

In contrast, the alternative is not true; the SelectorEventLoop cannot be used on Windows without causing issues, because it lacks support for multiple methods.

In particular, it does not implement the subprocess_exec and subprocess_shell methods.

That, in turn, means that Jupyter server extensions cannot use the asyncio.create_subprocess_exec and asyncio.create_subprocess_shell methods.

Further, because this policy setting (and event loop creation) is performed very early on, it's not feasible for a user to override this behavior in their Jupyter settings.

The end result is that it's not possible for Jupyter server extensions to use subprocesses to run external commands on Windows (at least, not asynchronously).

I would like to remove this barrier and make it possible for server extensions to do that.

Proposed Solution

The simplest solution is simply to remove the _init_asyncio_patch method.

This will cause deployments on Windows (with Python versions 3.14 and below) to use the default event loop policy, which uses the ProactorEventLoop.

More importantly, however, is that this will also remove a barrier from supporting the upcoming version 3.16 of Python, as all of these policy classes will be removed in that version

If that's not possible, then we should add a flag to allow the user to control this behavior; either by adding the ability to opt-out of using the SelectorEventLoop, or to require an opt-in to use it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions