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

This commit is contained in:
Ashley Sommer 2022-05-24 05:47:05 +10:00 committed by GitHub
parent 86ae5f981c
commit 4ee2e57ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -992,10 +992,10 @@ class Sanic(BaseSanic, RunnerMixin, metaclass=TouchUpMeta):
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: