Skip to content

Commit dd124dc

Browse files
committed
fmt
1 parent bb7d1cb commit dd124dc

3 files changed

Lines changed: 45 additions & 10 deletions

File tree

src/runloop_api_client/lib/polling_async.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ async def async_poll_until(
6161

6262

6363
async def retry_server_poll_until(
64-
retriever: Callable[[], Awaitable[T]],
64+
retriever: Callable[[float], Awaitable[T]],
6565
is_terminal: Callable[[T], bool],
6666
timeout_seconds: float = 30.0,
6767
on_error: Optional[Callable[[Exception], T]] = None,
@@ -70,8 +70,8 @@ async def retry_server_poll_until(
7070
Retry a server-side long-poll until a condition is met or max timeout is reached.
7171
7272
Args:
73-
retriever: Async or sync callable that returns the object to check. This takes should
74-
take one argument, which is the remaing time to poll.q
73+
retriever: Async callable that takes the remaining timeout (seconds) and
74+
returns the object to check.
7575
is_terminal: Callable that returns True when polling should stop
7676
timeout_seconds: Total time to wait. Must be > 0
7777
on_error: Optional error handler that can return a value to continue polling
@@ -83,12 +83,11 @@ async def retry_server_poll_until(
8383
Raises:
8484
PollingTimeout: When max attempts or timeout is reached
8585
"""
86-
start_time = time.time()
8786
last_result: Union[T, None] = None
87+
start_time = time.time()
8888

8989
while True:
90-
elapsed = time.time() - start_time
91-
remaining_time = timeout_seconds - elapsed
90+
remaining_time = timeout_seconds - (time.time() - start_time)
9291
if remaining_time <= 0:
9392
raise PollingTimeout(f"Exceeded timeout of {timeout_seconds} seconds", last_result)
9493

src/runloop_api_client/resources/devboxes/devboxes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,7 @@ async def await_running(
20552055
RunloopError: If devbox enters a non-running terminal state
20562056
"""
20572057

2058-
async def wait_for_devbox_status(remaining_timeout_seconds) -> DevboxView:
2058+
async def wait_for_devbox_status(remaining_timeout_seconds: float) -> DevboxView:
20592059
# This wait_for_status endpoint polls the devbox status for 10 seconds until it reaches either running or failure.
20602060
# If it's neither, it will throw an error.
20612061
try:

uv.lock

Lines changed: 39 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)