Skip to content

Switch to sansio websockets back-end#289

Open
rwb27 wants to merge 1 commit intomainfrom
websockets-sansio
Open

Switch to sansio websockets back-end#289
rwb27 wants to merge 1 commit intomainfrom
websockets-sansio

Conversation

@rwb27
Copy link
Collaborator

@rwb27 rwb27 commented Mar 5, 2026

Uvicorn uses the now deprecated websockets.legacy back end by default. It also supports the newer sansio interface. As far as I can tell, either works, so I'm not sure why legacy is the default: backwards compatibility I guess.

I'd like to switch to the newer implementation now, before we are using websockets in anger, as it feels wrong to start out with deprecation warnings in the test suite! I don't believe we will notice the difference, but hopefully the test suite will tell. Websockets aren't used yet by the OFM.

@barecheck
Copy link

barecheck bot commented Mar 5, 2026

Barecheck - Code coverage report

Total: 96.34%

Your code coverage diff: 0.00% ▴

Uncovered files and lines
FileLines
src/labthings_fastapi/server/cli.py102, 184

@rwb27 rwb27 added this to the v0.2.0 milestone Mar 9, 2026
Uvicorn uses the now deprecated `websockets.legacy` back end by default. It also supports the newer `sansio` interface. As far as I can tell, either works, so I'm not sure why legacy is the default: backwards compatibility I guess.

I'd like to switch to the newer implementation now, before we are using websockets in anger, as it feels wrong to start out with deprecation warnings in the test suite!
@rwb27 rwb27 force-pushed the websockets-sansio branch from a1db57e to f1dc80d Compare March 23, 2026 22:42
@rwb27 rwb27 requested a review from julianstirling March 25, 2026 10:17
Copy link
Contributor

@julianstirling julianstirling left a comment

Choose a reason for hiding this comment

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

This generally make sense. I think the worry is there will be inconsistent behaviour if people follow the example in tutorial/writing_a_thing.rst. Even though websockets are not in use it is probably worth updating that example.

This also relates to #263 as the OFM has its own uvicorn.run lines. I am not sure how best to wrap this so it can be enabled. But at the minimum I'd update the docs.

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.

2 participants