Catch unhandled exception in websocket_api (#42693)

Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
This commit is contained in:
SigmaPic 2020-11-03 10:35:45 +01:00 committed by GitHub
parent 349e4a5ac2
commit 51f847c4b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -222,11 +222,11 @@ class WebSocketHandler:
self._to_write.put_nowait(None)
# Make sure all error messages are written before closing
await self._writer_task
except asyncio.QueueFull:
await wsock.close()
except asyncio.QueueFull: # can be raised by put_nowait
self._writer_task.cancel()
await wsock.close()
finally:
if disconnect_warn is None:
self._logger.debug("Disconnected")
else: