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

Properly catch websocket CancelledError in websocket handler in Python 3.7 #2463

Merged
merged 1 commit into from May 23, 2022

Conversation

ashleysommer
Copy link
Member

In python 3.8 CancelledError is subclass of BaseException, but in Python 3.7 and earlier, it is subclass of Exception. That means in python 3.7, the CancelledError gets caught by the general Exception handler, and does not correctly handle the case of a cancelled websocket task.

Fixes #2462

…hon 3.7.

In python 3.8 `CancelledError` is subclass of `BaseException`, but in Python 3.7 and earlier, it is subclass of `Exception`. That means in python 3.7, the `CancelledError` gets caught by the general `Exception` handler, and does not correctly handle the case of a cancelled websocket task.

Fixes #2462
@ashleysommer ashleysommer requested a review from a team as a code owner May 23, 2022 13:06
@codecov
Copy link

codecov bot commented May 23, 2022

Codecov Report

Merging #2463 (3b499ef) into main (86ae5f9) will increase coverage by 0.079%.
The diff coverage is 100.000%.

@@              Coverage Diff              @@
##              main     #2463       +/-   ##
=============================================
+ Coverage   87.176%   87.255%   +0.079%     
=============================================
  Files           60        60               
  Lines         5061      5061               
  Branches       909       909               
=============================================
+ Hits          4412      4416        +4     
+ Misses         477       474        -3     
+ Partials       172       171        -1     
Impacted Files Coverage Δ
sanic/app.py 88.761% <100.000%> (+0.190%) ⬆️
sanic/server/protocols/http_protocol.py 88.095% <0.000%> (+3.571%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86ae5f9...3b499ef. Read the comment docs.

@ashleysommer ashleysommer changed the title Properly catched websocket CancelledError in websocket handler in Python 3.7 Properly catche websocket CancelledError in websocket handler in Python 3.7 May 23, 2022
@ashleysommer ashleysommer changed the title Properly catche websocket CancelledError in websocket handler in Python 3.7 Properly catch websocket CancelledError in websocket handler in Python 3.7 May 23, 2022
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.

Websocket disconnection and server task pending error
2 participants