@@ -3342,6 +3342,38 @@ def fetch_result() -> dict:
33423342 assert fetch_attempts ["count" ] == 0
33433343
33443344
3345+ def test_wait_for_job_result_does_not_retry_numeric_bytes_status_errors ():
3346+ status_attempts = {"count" : 0 }
3347+ fetch_attempts = {"count" : 0 }
3348+
3349+ def get_status () -> str :
3350+ status_attempts ["count" ] += 1
3351+ raise HyperbrowserError (
3352+ "client failure" ,
3353+ status_code = b"400" , # type: ignore[arg-type]
3354+ )
3355+
3356+ def fetch_result () -> dict :
3357+ fetch_attempts ["count" ] += 1
3358+ return {"ok" : True }
3359+
3360+ with pytest .raises (HyperbrowserError , match = "client failure" ):
3361+ wait_for_job_result (
3362+ operation_name = "sync wait helper status numeric-bytes client error" ,
3363+ get_status = get_status ,
3364+ is_terminal_status = lambda value : value == "completed" ,
3365+ fetch_result = fetch_result ,
3366+ poll_interval_seconds = 0.0001 ,
3367+ max_wait_seconds = 1.0 ,
3368+ max_status_failures = 5 ,
3369+ fetch_max_attempts = 5 ,
3370+ fetch_retry_delay_seconds = 0.0001 ,
3371+ )
3372+
3373+ assert status_attempts ["count" ] == 1
3374+ assert fetch_attempts ["count" ] == 0
3375+
3376+
33453377def test_wait_for_job_result_does_not_retry_broken_executor_status_errors ():
33463378 status_attempts = {"count" : 0 }
33473379 fetch_attempts = {"count" : 0 }
@@ -3887,6 +3919,34 @@ def fetch_result() -> dict:
38873919 assert fetch_attempts ["count" ] == 3
38883920
38893921
3922+ def test_wait_for_job_result_retries_numeric_bytes_rate_limit_fetch_errors ():
3923+ fetch_attempts = {"count" : 0 }
3924+
3925+ def fetch_result () -> dict :
3926+ fetch_attempts ["count" ] += 1
3927+ if fetch_attempts ["count" ] < 3 :
3928+ raise HyperbrowserError (
3929+ "rate limited" ,
3930+ status_code = b"429" , # type: ignore[arg-type]
3931+ )
3932+ return {"ok" : True }
3933+
3934+ result = wait_for_job_result (
3935+ operation_name = "sync wait helper fetch numeric-bytes rate limit" ,
3936+ get_status = lambda : "completed" ,
3937+ is_terminal_status = lambda value : value == "completed" ,
3938+ fetch_result = fetch_result ,
3939+ poll_interval_seconds = 0.0001 ,
3940+ max_wait_seconds = 1.0 ,
3941+ max_status_failures = 5 ,
3942+ fetch_max_attempts = 5 ,
3943+ fetch_retry_delay_seconds = 0.0001 ,
3944+ )
3945+
3946+ assert result == {"ok" : True }
3947+ assert fetch_attempts ["count" ] == 3
3948+
3949+
38903950def test_wait_for_job_result_retries_request_timeout_fetch_errors ():
38913951 fetch_attempts = {"count" : 0 }
38923952
@@ -4064,6 +4124,41 @@ async def fetch_result() -> dict:
40644124 asyncio .run (run ())
40654125
40664126
4127+ def test_wait_for_job_result_async_does_not_retry_numeric_bytes_status_errors ():
4128+ async def run () -> None :
4129+ status_attempts = {"count" : 0 }
4130+ fetch_attempts = {"count" : 0 }
4131+
4132+ async def get_status () -> str :
4133+ status_attempts ["count" ] += 1
4134+ raise HyperbrowserError (
4135+ "client failure" ,
4136+ status_code = b"404" , # type: ignore[arg-type]
4137+ )
4138+
4139+ async def fetch_result () -> dict :
4140+ fetch_attempts ["count" ] += 1
4141+ return {"ok" : True }
4142+
4143+ with pytest .raises (HyperbrowserError , match = "client failure" ):
4144+ await wait_for_job_result_async (
4145+ operation_name = "async wait helper status numeric-bytes client error" ,
4146+ get_status = get_status ,
4147+ is_terminal_status = lambda value : value == "completed" ,
4148+ fetch_result = fetch_result ,
4149+ poll_interval_seconds = 0.0001 ,
4150+ max_wait_seconds = 1.0 ,
4151+ max_status_failures = 5 ,
4152+ fetch_max_attempts = 5 ,
4153+ fetch_retry_delay_seconds = 0.0001 ,
4154+ )
4155+
4156+ assert status_attempts ["count" ] == 1
4157+ assert fetch_attempts ["count" ] == 0
4158+
4159+ asyncio .run (run ())
4160+
4161+
40674162def test_wait_for_job_result_async_does_not_retry_broken_executor_status_errors ():
40684163 async def run () -> None :
40694164 status_attempts = {"count" : 0 }
@@ -4660,6 +4755,37 @@ async def fetch_result() -> dict:
46604755 asyncio .run (run ())
46614756
46624757
4758+ def test_wait_for_job_result_async_retries_numeric_bytes_rate_limit_fetch_errors ():
4759+ async def run () -> None :
4760+ fetch_attempts = {"count" : 0 }
4761+
4762+ async def fetch_result () -> dict :
4763+ fetch_attempts ["count" ] += 1
4764+ if fetch_attempts ["count" ] < 3 :
4765+ raise HyperbrowserError (
4766+ "rate limited" ,
4767+ status_code = b"429" , # type: ignore[arg-type]
4768+ )
4769+ return {"ok" : True }
4770+
4771+ result = await wait_for_job_result_async (
4772+ operation_name = "async wait helper fetch numeric-bytes rate limit" ,
4773+ get_status = lambda : asyncio .sleep (0 , result = "completed" ),
4774+ is_terminal_status = lambda value : value == "completed" ,
4775+ fetch_result = fetch_result ,
4776+ poll_interval_seconds = 0.0001 ,
4777+ max_wait_seconds = 1.0 ,
4778+ max_status_failures = 5 ,
4779+ fetch_max_attempts = 5 ,
4780+ fetch_retry_delay_seconds = 0.0001 ,
4781+ )
4782+
4783+ assert result == {"ok" : True }
4784+ assert fetch_attempts ["count" ] == 3
4785+
4786+ asyncio .run (run ())
4787+
4788+
46634789def test_wait_for_job_result_async_retries_request_timeout_fetch_errors ():
46644790 async def run () -> None :
46654791 fetch_attempts = {"count" : 0 }
0 commit comments