Skip to content

Commit 7ac0125

Browse files
authored
Merge pull request #119 from rmorshea/patch-1
WebsocketHandler.get is async
2 parents 5725b41 + 684da6e commit 7ac0125

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

jupyter_server_proxy/websocket.py

Lines changed: 9 additions & 3 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):
@@ -85,9 +92,8 @@ def undisallow(*args2, **kwargs2):
8592
async def get(self, *args, **kwargs):
8693
if self.request.headers.get("Upgrade", "").lower() != 'websocket':
8794
return await self.http_get(*args, **kwargs)
88-
# super get is not async
89-
super().get(*args, **kwargs)
90-
95+
else:
96+
await maybe_future(super().get(*args, **kwargs))
9197

9298

9399
def setup_handlers(web_app):

0 commit comments

Comments
 (0)