Skip to content

Commit

Permalink
Properly catch websocket CancelledError in websocket handler in Pytho…
Browse files Browse the repository at this point in the history
…n 3.7 (#2463)
  • Loading branch information
ashleysommer committed May 23, 2022
1 parent 86ae5f9 commit 4ee2e57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sanic/app.py
Expand Up @@ -992,10 +992,10 @@ async def _websocket_handler(
cancelled = False
try:
await fut
except Exception as e:
self.error_handler.log(request, e)
except (CancelledError, ConnectionClosed):
cancelled = True
except Exception as e:
self.error_handler.log(request, e)
finally:
self.websocket_tasks.remove(fut)
if cancelled:
Expand Down

0 comments on commit 4ee2e57

Please sign in to comment.