Properly catch websocket CancelledError in websocket handler in Python 3.7
(cherry picked from commit 4ee2e57ec8
)
This commit is contained in:
parent
c4da66bf1f
commit
698a359808
|
@ -1004,10 +1004,10 @@ class Sanic(BaseSanic, 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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user