Skip to content

Commit 846354d

Browse files
authored
Use maybe_future from notebook or tornado
1 parent b87ae4d commit 846354d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

jupyter_server_proxy/websocket.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
from notebook.utils import url_path_join
1515
from notebook.base.handlers import IPythonHandler, utcnow
1616

17+
try:
18+
# Tornado 6.0 deprecated its `maybe_future` function so `notebook` made their own.
19+
# See: https://github.com/jupyter/notebook/pull/4453
20+
from notebook.utils import maybe_future
21+
except ImportError:
22+
# We can't find it in `notebook` then we should be able to find it in Tornado
23+
from tornado.gen import maybe_future
1724

1825

1926
class PingableWSClientConnection(websocket.WebSocketClientConnection):
@@ -86,10 +93,7 @@ async def get(self, *args, **kwargs):
8693
if self.request.headers.get("Upgrade", "").lower() != 'websocket':
8794
return await self.http_get(*args, **kwargs)
8895
else:
89-
result = super().get(*args, **kwargs)
90-
if inspect.isawaitable(result):
91-
await result
92-
96+
awwait maybe_future(super().get(*args, **kwargs))
9397

9498

9599
def setup_handlers(web_app):

0 commit comments

Comments
 (0)