@@ -1086,13 +1086,12 @@ async def _do_ensure_connected[HandshakeMetadata](
10861086 last_error : Exception | None = None
10871087 attempt_count = 0
10881088
1089- handshake_deadline_ms = (
1089+ handshake_deadline = (
10901090 get_current_time () + transport_options .handshake_timeout_ms / 1000
10911091 )
10921092
10931093 while (
1094- rate_limiter .has_budget (client_id )
1095- and get_current_time () < handshake_deadline_ms
1094+ rate_limiter .has_budget (client_id ) and get_current_time () < handshake_deadline
10961095 ):
10971096 if (state := get_state ()) in TerminalStates or state in ActiveStates :
10981097 logger .info (f"_do_ensure_connected stopping due to state={ state } " )
@@ -1154,14 +1153,14 @@ async def websocket_closed_callback() -> None:
11541153 "Handshake failed, conn closed while sending response" ,
11551154 ) from e
11561155
1157- if get_current_time () >= handshake_deadline_ms :
1156+ if get_current_time () >= handshake_deadline :
11581157 raise RiverException (
11591158 ERROR_HANDSHAKE ,
11601159 "Handshake response timeout, closing connection" ,
11611160 )
11621161
11631162 try :
1164- timeout = handshake_deadline_ms - get_current_time () / 1000.0
1163+ timeout = handshake_deadline - get_current_time ()
11651164 async with asyncio .timeout (timeout ):
11661165 data = await ws .recv (decode = False )
11671166 except ConnectionClosedOK :
@@ -1237,15 +1236,15 @@ async def websocket_closed_callback() -> None:
12371236 transition_connected (ws )
12381237 break
12391238 except Exception as e :
1240- backoff_time = rate_limiter .get_backoff_ms (client_id )
1239+ backoff_time_ms = rate_limiter .get_backoff_ms (client_id )
12411240 logger .exception (
1242- f"Error connecting, retrying with { backoff_time } ms backoff"
1241+ f"Error connecting, retrying with { backoff_time_ms } ms backoff"
12431242 )
12441243 if ws :
12451244 close_ws_in_background (ws )
12461245 ws = None
12471246 last_error = e
1248- await asyncio .sleep (backoff_time / 1000 )
1247+ await asyncio .sleep (backoff_time_ms / 1000 )
12491248 logger .debug ("Here, about to retry" )
12501249 unbind_connecting_task ()
12511250
0 commit comments