Skip to content

Commit f616783

Browse files
Adding some more safeguards
1 parent 9010fbb commit f616783

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/replit_river/v2/session.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1090,11 +1090,17 @@ async def _do_ensure_connected[HandshakeMetadata](
10901090
get_current_time() + transport_options.handshake_timeout_ms / 1000
10911091
)
10921092

1093-
while rate_limiter.has_budget(client_id):
1093+
while (
1094+
rate_limiter.has_budget(client_id)
1095+
and get_current_time() < handshake_deadline_ms
1096+
):
10941097
if (state := get_state()) in TerminalStates or state in ActiveStates:
10951098
logger.info(f"_do_ensure_connected stopping due to state={state}")
10961099
break
10971100

1101+
if (task := asyncio.current_task()) and task.cancelled():
1102+
break
1103+
10981104
if attempt_count > 0:
10991105
logger.info(f"Retrying build handshake number {attempt_count} times")
11001106
attempt_count += 1

0 commit comments

Comments
 (0)