(websockets 12.0) DeprecationWarning: websockets.connection was renamed to websockets.protocol and Connection was renamed to Protocol
Gerhut opened this issue · comments
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
The DeprecationWarning is thrown here:
sanic/sanic/server/protocols/websocket_protocol.py
Lines 4 to 9 in 82bf46b
With websockets 12 the try block would run successfully with the warning while the catch block does not have chance to be run.
Code snippet
No response
Expected Behavior
The catch block is being run instead.
How do you run Sanic?
Sanic CLI
Operating System
MacOS
Sanic Version
Sanic 23.6.0; Routing 23.6.0
Additional context
No response
Although it triggers a deprecation warning, the try...except...
block will work when the classes are actually removed in websockets
package in the future. Checking version of a package requires an additional dependency packaging
, which we wouldn't like to add, thus I think we can just ignore the warning.
See more discussion in #2880
Although it triggers a deprecation warning, the
try...except...
block will work when the classes are actually removed inwebsockets
package in the future. Checking version of a package requires an additional dependencypackaging
, which we wouldn't like to add, thus I think we can just ignore the warning.
Can't you try
the new API, which will give ImportError or such but no deprecation warnings, and except
fallback to old API?
Looks like you can also use websockets.__version__
for a version string.