Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the event loop policy on Windows #65

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions nbsmoke/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import io
import contextlib
import sys

import param

Expand Down Expand Up @@ -91,6 +92,27 @@ def cwd(d):
os.chdir(orig)


def fixup_windows_event_loop_policy() -> None:
try:
import tornado
except ImportError:
tornado = None
if not tornado:
return
# This part of the code comes from Bokeh's source code.
if (
sys.platform == 'win32'
and sys.version_info[:3] >= (3, 8, 0)
and tornado.version_info < (6, 1)
):
import asyncio
if type(asyncio.get_event_loop_policy()) is asyncio.WindowsProactorEventLoopPolicy:
# WindowsProactorEventLoopPolicy is not compatible with tornado 6
# fallback to the pre-3.8 default of WindowsSelectorEventLoopPolicy
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())


fixup_windows_event_loop_policy()

###################################################

Expand Down