Skip to content

Commit 8524466

Browse files
committed
fix #208: workaround incompatibility between python3.8 default event loop for Windows and Tornado
1 parent fd4e4ea commit 8524466

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

doc/source/changes/version_0_33.rst.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ Miscellaneous improvements
3838
Fixes
3939
^^^^^
4040

41-
* fixed something (closes :editor_issue:`1`).
41+
* workaround incompatibility with Python3.8 on Windows (closes :editor_issue:`208`).

larray_editor/editor.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
import os
22
import re
3+
import sys
4+
5+
# Python3.8 switched from a Selector to a Proactor based event loop for asyncio but they do not offer the same
6+
# features, which breaks Tornado and all projects depending on it, including Jupyter consoles
7+
# refs: https://github.com/larray-project/larray-editor/issues/208
8+
if sys.platform.startswith("win") and sys.version_info >= (3, 8):
9+
import asyncio
10+
11+
try:
12+
from asyncio import WindowsProactorEventLoopPolicy, WindowsSelectorEventLoopPolicy
13+
except ImportError:
14+
# not affected
15+
pass
16+
else:
17+
if type(asyncio.get_event_loop_policy()) is WindowsProactorEventLoopPolicy:
18+
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
319

420
import matplotlib
521
import matplotlib.axes

0 commit comments

Comments
 (0)