Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List tornado and traitlets as dependencies explicitly, and cleanup unreachable code #457

Merged
merged 2 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
os: [ubuntu-22.04, windows-2022]
python-version: ["3.8", "3.11"]
pip-extras: ["lab", "classic"]
pip-install-constraints: [""]
exclude:
# windows should work for all test variations, but a limited selection
# is run to avoid doubling the amount of test runs
Expand All @@ -86,6 +87,17 @@ jobs:
python-version: "3.8"
pip-extras: lab

# this test is manually updated to reflect the lower bounds of
# versions from dependencies
- os: ubuntu-22.04
python-version: "3.8"
pip-extras: classic
pip-install-constraints: >-
jupyter-server==1.0
simpervisor==1.0
tornado==5.0
traitlets==4.2.1

steps:
- uses: actions/checkout@v4

Expand All @@ -108,7 +120,7 @@ jobs:
#
# Pytest options are set in `pyproject.toml`.
run: |
pip install -vv $(ls ./dist/*.whl)\[acceptance,${{ matrix.pip-extras }}\]
pip install -vv $(ls ./dist/*.whl)\[acceptance,${{ matrix.pip-extras }}\] ${{ matrix.pip-install-constraints }}

- name: List Python packages
run: |
Expand Down
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,
)
Comment on lines -43 to -51
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cleaned up now that we know we required tornado 5.0 via jupyter server 1.0.0+.

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,
)
Comment on lines +43 to +57
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was just indentation changes by no longer nesting under an else clause.


return conn.connect_future

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ dependencies = [
"importlib_metadata >=4.8.3 ; python_version<\"3.10\"",
"jupyter-server >=1.0",
"simpervisor >=1.0",
"tornado >=5.0",
"traitlets >= 4.2.1",
]

[project.optional-dependencies]
Expand Down