@@ -1286,8 +1286,8 @@ async def _recv_from_ws(
12861286 """
12871287 our_task = asyncio .current_task ()
12881288 connection_attempts = 0
1289- try :
1290- while our_task and not our_task . cancelling () and not our_task . cancelled () :
1289+ while our_task and not our_task . cancelling () and not our_task . cancelled () :
1290+ try :
12911291 logger .debug (f"_recv_from_ws loop count={ connection_attempts } " )
12921292 connection_attempts += 1
12931293 ws = None
@@ -1424,23 +1424,24 @@ async def _recv_from_ws(
14241424 logger .debug (
14251425 "FailedSendingMessageException while serving" , exc_info = True
14261426 )
1427- break
1427+ break # Inner loop
14281428 except Exception :
14291429 logger .exception ("caught exception at message iterator" )
1430- break
1430+ await transition_no_connection ()
1431+ break # Inner loop
14311432 logger .debug ("_handle_messages_from_ws exiting" )
1432- except ExceptionGroup as eg :
1433- _ , unhandled = eg .split (lambda e : isinstance (e , ConnectionClosed ))
1434- if unhandled :
1435- # We're in a task, there's not that much that can be done.
1436- unhandled = ExceptionGroup (
1437- "Unhandled exceptions on River server" , unhandled .exceptions
1438- )
1439- logger .exception (
1440- "caught exception at message iterator" ,
1441- exc_info = unhandled ,
1442- )
1443- raise unhandled
1433+ except ExceptionGroup as eg :
1434+ _ , unhandled = eg .split (lambda e : isinstance (e , ConnectionClosed ))
1435+ if unhandled :
1436+ # We're in a task, there's not that much that can be done.
1437+ unhandled = ExceptionGroup (
1438+ "Unhandled exceptions on River server" , unhandled .exceptions
1439+ )
1440+ logger .exception (
1441+ "caught exception at message iterator" ,
1442+ exc_info = unhandled ,
1443+ )
1444+ raise unhandled
14441445 logger .debug (f"_recv_from_ws exiting normally after { connection_attempts } loops" )
14451446
14461447
0 commit comments