@@ -30,6 +30,11 @@ def _validate_poll_interval(poll_interval_seconds: float) -> None:
3030 raise HyperbrowserError ("poll_interval_seconds must be non-negative" )
3131
3232
33+ def _validate_max_wait_seconds (max_wait_seconds : Optional [float ]) -> None :
34+ if max_wait_seconds is not None and max_wait_seconds < 0 :
35+ raise HyperbrowserError ("max_wait_seconds must be non-negative" )
36+
37+
3338def has_exceeded_max_wait (start_time : float , max_wait_seconds : Optional [float ]) -> bool :
3439 return (
3540 max_wait_seconds is not None
@@ -47,6 +52,7 @@ def poll_until_terminal_status(
4752 max_status_failures : int = 5 ,
4853) -> str :
4954 _validate_poll_interval (poll_interval_seconds )
55+ _validate_max_wait_seconds (max_wait_seconds )
5056 _validate_retry_config (
5157 max_attempts = 1 ,
5258 retry_delay_seconds = 0 ,
@@ -112,6 +118,7 @@ async def poll_until_terminal_status_async(
112118 max_status_failures : int = 5 ,
113119) -> str :
114120 _validate_poll_interval (poll_interval_seconds )
121+ _validate_max_wait_seconds (max_wait_seconds )
115122 _validate_retry_config (
116123 max_attempts = 1 ,
117124 retry_delay_seconds = 0 ,
@@ -178,6 +185,7 @@ def collect_paginated_results(
178185 max_attempts : int ,
179186 retry_delay_seconds : float ,
180187) -> None :
188+ _validate_max_wait_seconds (max_wait_seconds )
181189 _validate_retry_config (
182190 max_attempts = max_attempts ,
183191 retry_delay_seconds = retry_delay_seconds ,
@@ -220,6 +228,7 @@ async def collect_paginated_results_async(
220228 max_attempts : int ,
221229 retry_delay_seconds : float ,
222230) -> None :
231+ _validate_max_wait_seconds (max_wait_seconds )
223232 _validate_retry_config (
224233 max_attempts = max_attempts ,
225234 retry_delay_seconds = retry_delay_seconds ,
@@ -269,6 +278,7 @@ def wait_for_job_result(
269278 max_status_failures = max_status_failures ,
270279 )
271280 _validate_poll_interval (poll_interval_seconds )
281+ _validate_max_wait_seconds (max_wait_seconds )
272282 poll_until_terminal_status (
273283 operation_name = operation_name ,
274284 get_status = get_status ,
@@ -303,6 +313,7 @@ async def wait_for_job_result_async(
303313 max_status_failures = max_status_failures ,
304314 )
305315 _validate_poll_interval (poll_interval_seconds )
316+ _validate_max_wait_seconds (max_wait_seconds )
306317 await poll_until_terminal_status_async (
307318 operation_name = operation_name ,
308319 get_status = get_status ,
0 commit comments