Skip to content

Commit 95c5c11

Browse files
committed
use utils from jupyter-server
1 parent ade3306 commit 95c5c11

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

nbclassic/bundler/handlers.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,30 @@
66
from ipython_genutils.importstring import import_item
77
from tornado import web, gen
88

9-
from nbclassic.utils import maybe_future, url2path
9+
from jupyter_server.utils import url2path
1010
from nbclassic.base.handlers import IPythonHandler
1111
from nbclassic.services.config import ConfigManager
1212

1313
from . import tools
1414

1515

16+
def maybe_future(obj):
17+
"""Like tornado's deprecated gen.maybe_future
18+
19+
but more compatible with asyncio for recent versions
20+
of tornado
21+
"""
22+
if inspect.isawaitable(obj):
23+
return asyncio.ensure_future(obj)
24+
elif isinstance(obj, concurrent.futures.Future):
25+
return asyncio.wrap_future(obj)
26+
else:
27+
# not awaitable, wrap scalar in future
28+
f = asyncio.Future()
29+
f.set_result(obj)
30+
return f
31+
32+
1633
class BundlerHandler(IPythonHandler):
1734
def initialize(self):
1835
"""Make tools module available on the handler instance for compatibility

nbclassic/tests/selenium/test_dashboard_nav.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22

3-
from nbclassic.utils import url_path_join
3+
from jupyter_server.utils import url_path_join
44
from nbclassic.tests.selenium.utils import wait_for_selector
55
pjoin = os.path.join
66

0 commit comments

Comments
 (0)