Ignore closed connections in response to quit requests
@@ -36,16 +36,14 @@ class Protocol:
try:
await self._ws.send_bytes(request.SerializeToString())
except TypeError:
- logger.exception("Cannot send: Connection already closed.")
- raise ConnectionAlreadyClosed("Connection already closed.")
+ raise ConnectionAlreadyClosed("Cannot send: Connection already closed.")
logger.debug(f"Request sent")
response = sc_pb.Response()
try:
response_bytes = await self._ws.receive_bytes()
except TypeError:
- logger.exception("Cannot receive: Connection already closed.")
- raise ConnectionAlreadyClosed("Connection already closed.")
+ raise ConnectionAlreadyClosed("Cannot receive: Connection already closed.")
except asyncio.CancelledError:
# If request is sent, the response must be received before reraising cancel
try:
@@ -82,4 +80,7 @@ class Protocol:
return result
async def quit(self):
+ try:
await self._execute(quit=sc_pb.RequestQuit())
+ except ConnectionAlreadyClosed:
+ pass
