@@ -61,7 +61,7 @@ async def async_poll_until(
6161
6262
6363async 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
0 commit comments