app.py: Work around incompatibility between Tornado 6 and asyncio proactor event loop in python 3.8 on Windows #3123
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In py38, asyncio made the
WindowsProactorEventLoopPolicy
the default setting for event loops on Windows. However, this is incompatible with Tornado. The result is that the Hub does not start on Windows on Python 3.8, with aNotImplementedError
. See tornadoweb/tornado#2608 for additional context.The workaround suggested by Tornado is to use the older
WindowsSelectorEventLoopPolicy
, which is the default in py37 and before. This is done via:This workaround has already been applied in the single-user server: jupyter/notebook#5047. The content of this PR is almost identical to the single-user one, save for some formatting differences. We only alter the default setting if we're running in an environment where this issue might occur (Windows, py38, and a sufficiently advanced asyncio API).