Skip to content

Commit

Permalink
Remove unreachable code for tornado 4
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Feb 21, 2024
1 parent 26b59d8 commit 0ecfdea
Showing 1 changed file with 16 additions and 26 deletions.
42 changes: 16 additions & 26 deletions jupyter_server_proxy/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import inspect

from jupyter_server.utils import ensure_async
from tornado import httpclient, httputil, ioloop, version_info, websocket
from tornado import httpclient, httputil, websocket


class PingableWSClientConnection(websocket.WebSocketClientConnection):
Expand Down Expand Up @@ -40,31 +40,21 @@ def pingable_ws_connect(
request.headers = httputil.HTTPHeaders(request.headers)
request = httpclient._RequestProxy(request, httpclient.HTTPRequest._DEFAULTS)

# for tornado 4.5.x compatibility
if version_info[0] == 4:
conn = PingableWSClientConnection(
io_loop=ioloop.IOLoop.current(),
compression_options={},
request=request,
on_message_callback=on_message_callback,
on_ping_callback=on_ping_callback,
)
else:
# resolver= parameter requires tornado >= 6.3. Only pass it if needed
# (for Unix socket support), so older versions of tornado can still
# work otherwise.
kwargs = {"resolver": resolver} if resolver else {}
conn = PingableWSClientConnection(
request=request,
compression_options={},
on_message_callback=on_message_callback,
on_ping_callback=on_ping_callback,
max_message_size=getattr(
websocket, "_default_max_message_size", 10 * 1024 * 1024
),
subprotocols=subprotocols,
**kwargs,
)
# resolver= parameter requires tornado >= 6.3. Only pass it if needed
# (for Unix socket support), so older versions of tornado can still
# work otherwise.
kwargs = {"resolver": resolver} if resolver else {}
conn = PingableWSClientConnection(
request=request,
compression_options={},
on_message_callback=on_message_callback,
on_ping_callback=on_ping_callback,
max_message_size=getattr(
websocket, "_default_max_message_size", 10 * 1024 * 1024
),
subprotocols=subprotocols,
**kwargs,
)

return conn.connect_future

Expand Down

0 comments on commit 0ecfdea

Please sign in to comment.