File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -1105,6 +1105,7 @@ async def _setup_heartbeat(
11051105 while True :
11061106 while (state := get_state ()) in ConnectingStates :
11071107 await block_until_connected ()
1108+
11081109 if state in TerminalStates :
11091110 logger .debug (
11101111 "Session is closed, no need to send heartbeat, state : "
@@ -1156,9 +1157,17 @@ async def _serve(
11561157 while our_task and not our_task .cancelling () and not our_task .cancelled ():
11571158 logger .debug (f"_serve loop count={ idx } " )
11581159 idx += 1
1159- while (ws := get_ws ()) is None or get_state () in ConnectingStates :
1160+ while (ws := get_ws ()) is None or ( state := get_state () ) in ConnectingStates :
11601161 logger .debug ("_handle_messages_from_ws spinning while connecting" )
11611162 await block_until_connected ()
1163+
1164+ if state in TerminalStates :
1165+ logger .debug (
1166+ f"Session is { state } , shut down _serve" ,
1167+ )
1168+ # session is closing / closed, no need to serve anymore
1169+ break
1170+
11621171 logger .debug (
11631172 "%s start handling messages from ws %s" ,
11641173 "client" ,
You can’t perform that action at this time.
0 commit comments