@@ -368,7 +368,7 @@ async def close(self, to_reconnect: bool = False):
368368 await asyncio .gather (* tasks_need_to_be_gathered )
369369 except asyncio .CancelledError :
370370 pass
371- except websockets .exceptions . ConnectionClosed :
371+ except websockets .ConnectionClosed :
372372 pass
373373
374374 self ._pinger_task = None
@@ -380,7 +380,7 @@ async def close(self, to_reconnect: bool = False):
380380
381381 async def _recv (self , request_id : int ) -> dict [str , Any ]:
382382 if not self .is_open :
383- raise websockets .exceptions . ConnectionClosedOK (None , None )
383+ raise websockets .ConnectionClosedOK (rcvd = None , sent = None )
384384 try :
385385 return await self .messages .get (request_id )
386386 except GeneratorExit :
@@ -463,7 +463,7 @@ async def _debug_logger(self):
463463 except asyncio .CancelledError :
464464 asyncio .create_task (self .close (), name = "Task_Close" ) # noqa: RUF006
465465 raise
466- except websockets .exceptions . ConnectionClosed :
466+ except websockets .ConnectionClosed :
467467 log .warning ("Debug Logger: Connection closed, reconnecting" )
468468 # the reconnect has to be done as a task because the receiver will
469469 # be cancelled by the reconnect and we don't want the reconnect
@@ -489,7 +489,7 @@ async def _receiver(self):
489489 except asyncio .CancelledError :
490490 log .debug ("Receiver: Cancelled" )
491491 pass
492- except websockets .exceptions . ConnectionClosed as e :
492+ except websockets .ConnectionClosed as e :
493493 log .warning ("Receiver: Connection closed, reconnecting" )
494494 await self .messages .put_all (e )
495495 # the reconnect has to be done as a task because the receiver will
@@ -530,7 +530,7 @@ async def _do_ping():
530530 except asyncio .CancelledError :
531531 log .debug ("Pinger: Cancelled" )
532532 pass
533- except websockets .exceptions . ConnectionClosed :
533+ except websockets .ConnectionClosed :
534534 # The connection has closed - we can't do anything
535535 # more until the connection is restarted.
536536 log .debug ("ping failed because of closed connection" )
@@ -568,11 +568,8 @@ async def rpc(
568568 for attempt in range (3 ):
569569 if self .monitor .status == Monitor .DISCONNECTED :
570570 # closed cleanly; shouldn't try to reconnect
571- raise websockets .exceptions .ConnectionClosed (
572- websockets .frames .Close (
573- websockets .frames .CloseCode .NORMAL_CLOSURE , "websocket closed"
574- )
575- )
571+ # we're trying to use a reference to a monitor that was cleanly closed earlier
572+ raise websockets .ConnectionClosedOK (rcvd = None , sent = None )
576573 try :
577574 await self ._ws .send (outgoing )
578575 break
0 commit comments