Skip to content

Commit eff9b0a

Browse files
committed
Cap anyio < 3 for python < 3.7
1 parent 02d2e8b commit eff9b0a

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

jupyter_server/services/contents/filecheckpoints.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@
1414
)
1515
from .fileio import AsyncFileManagerMixin, FileManagerMixin
1616

17-
from anyio.to_thread import run_sync
17+
try:
18+
from anyio.to_thread import run_sync
19+
except ImportError:
20+
# fallback on anyio v2 for python version < 3.7
21+
from anyio import run_sync_in_worker_thread as run_sync
22+
1823
from jupyter_core.utils import ensure_dir_exists
1924
from traitlets import Unicode
2025

jupyter_server/services/contents/fileio.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import os
1313
import shutil
1414

15-
from anyio.to_thread import run_sync
15+
try:
16+
from anyio.to_thread import run_sync
17+
except ImportError:
18+
# fallback on anyio v2 for python version < 3.7
19+
from anyio import run_sync_in_worker_thread as run_sync
20+
1621
from tornado.web import HTTPError
1722

1823
from jupyter_server.utils import (

jupyter_server/services/contents/filemanager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
import mimetypes
1313
import nbformat
1414

15-
from anyio.to_thread import run_sync
15+
try:
16+
from anyio.to_thread import run_sync
17+
except ImportError:
18+
# fallback on anyio v2 for python version < 3.7
19+
from anyio import run_sync_in_worker_thread as run_sync
20+
1621
from send2trash import send2trash
1722
from tornado import web
1823

jupyter_server/services/contents/largefilemanager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from anyio.to_thread import run_sync
1+
try:
2+
from anyio.to_thread import run_sync
3+
except ImportError:
4+
# fallback on anyio v2 for python version < 3.7
5+
from anyio import run_sync_in_worker_thread as run_sync
6+
27
from tornado import web
38
import base64
49
import os, io

setup.cfg

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ install_requires =
4242
terminado>=0.8.3
4343
prometheus_client
4444
pywin32>=1.0 ; sys_platform == 'win32'
45-
anyio>=3.0.1,<4
45+
anyio>=2.0.2,<3 ; python_version < '3.7'
46+
anyio>=3.0.1,<4 ; python_version >= '3.7'
4647

4748
[options.extras_require]
4849
test = coverage; pytest; pytest-cov; pytest-mock; requests; pytest-tornasync; pytest-console-scripts; ipykernel

0 commit comments

Comments
 (0)