Skip to content

Commit 66d6c60

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: inline remaining alias in _read_agent_stream timeout calc
The `remaining = deadline - time.monotonic()` local served a single use on the very next line as `max(remaining, 0)`. Collapsing to `max(deadline - time.monotonic(), 0)` matches the inline-alias style established by e1ad87a (`binary`), 497c028 (`agent`), fc5e1cb (`total_in`), 52e0272 (`msg`), and ce487d3 (`text`). Updated the adjacent comment to refer to "clamp to 0" since the `remaining` name no longer exists. Behavior preserved — same value reaches `line_q.get(timeout=...)` on every iteration of the read loop. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent 68c3def commit 66d6c60

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

src/ralphify/_agent.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,10 @@ def _read_agent_stream(
347347
while True:
348348
# Compute how long we can wait for the next line.
349349
if deadline is not None:
350-
remaining = deadline - time.monotonic()
351-
# Use max(remaining, 0) so that an already-expired deadline
352-
# still does a non-blocking drain of queued lines before
353-
# returning — lines the reader thread already buffered are
354-
# not silently lost.
355-
get_timeout: float | None = max(remaining, 0)
350+
# Clamp to 0 so that an already-expired deadline still does a
351+
# non-blocking drain of queued lines before returning — lines
352+
# the reader thread already buffered are not silently lost.
353+
get_timeout: float | None = max(deadline - time.monotonic(), 0)
356354
else:
357355
get_timeout = None
358356

0 commit comments

Comments
 (0)