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

DM-38425: Switch to websockets #248

Merged
merged 2 commits into from
May 11, 2023
Merged

DM-38425: Switch to websockets #248

merged 2 commits into from
May 11, 2023

Conversation

rra
Copy link
Member

@rra rra commented May 11, 2023

httpx-ws seems unable to talk to Jupyter labs. Connecting to a wss URL returns a 400 error and connecting to an https URL returns a timeout error, both without any error messages on the server side that I can find. Switch to the websockets library instead, which was already successfully in use by noteburst.

websockets unfortunately doesn't use the underlying httpx AsyncClient, so requires copying some headers from an AsyncClient request to get the authentication information.

Move the creation of the lab session into the JupyterLabSession context manager so that the calling convention is less awkward (no extra await in the middle of the context manager invocation). This code uses an explicit context manager because when using one generated with asynccontextmanager the WebSocket wasn't closed until garbage collection, at which point the AsyncClient was already closed and the lab session couldn't be deleted. This approach allows tighter control over exactly when the lab session is deleted.

httpx-ws seems unable to talk to Jupyter labs. Connecting to a wss
URL returns a 400 error and connecting to an https URL returns a
timeout error, both without any error messages on the server side
that I can find. Switch to the websockets library instead, which was
already successfully in use by noteburst.

websockets unfortunately doesn't use the underlying httpx AsyncClient,
so requires copying some headers from an AsyncClient request to get
the authentication information.

Move the creation of the lab session into the JupyterLabSession
context manager so that the calling convention is less awkward (no
extra await in the middle of the context manager invocation). This
code uses an explicit context manager because when using one
generated with asynccontextmanager the WebSocket wasn't closed until
garbage collection, at which point the AsyncClient was already closed
and the lab session couldn't be deleted. This approach allows tighter
control over exactly when the lab session is deleted.
@rra rra merged commit 0966630 into main May 11, 2023
@rra rra deleted the tickets/DM-38425 branch May 11, 2023 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant