@@ -3014,6 +3014,37 @@ def fetch_result() -> dict:
30143014 assert fetch_attempts ["count" ] == 0
30153015
30163016
3017+ def test_wait_for_job_result_does_not_retry_executor_shutdown_status_errors ():
3018+ status_attempts = {"count" : 0 }
3019+ fetch_attempts = {"count" : 0 }
3020+
3021+ def get_status () -> str :
3022+ status_attempts ["count" ] += 1
3023+ raise RuntimeError ("cannot schedule new futures after shutdown" )
3024+
3025+ def fetch_result () -> dict :
3026+ fetch_attempts ["count" ] += 1
3027+ return {"ok" : True }
3028+
3029+ with pytest .raises (
3030+ RuntimeError , match = "cannot schedule new futures after shutdown"
3031+ ):
3032+ wait_for_job_result (
3033+ operation_name = "sync wait helper status executor-shutdown" ,
3034+ get_status = get_status ,
3035+ is_terminal_status = lambda value : value == "completed" ,
3036+ fetch_result = fetch_result ,
3037+ poll_interval_seconds = 0.0001 ,
3038+ max_wait_seconds = 1.0 ,
3039+ max_status_failures = 5 ,
3040+ fetch_max_attempts = 5 ,
3041+ fetch_retry_delay_seconds = 0.0001 ,
3042+ )
3043+
3044+ assert status_attempts ["count" ] == 1
3045+ assert fetch_attempts ["count" ] == 0
3046+
3047+
30173048def test_wait_for_job_result_does_not_retry_timeout_status_errors ():
30183049 status_attempts = {"count" : 0 }
30193050 fetch_attempts = {"count" : 0 }
@@ -3246,6 +3277,31 @@ def fetch_result() -> dict:
32463277 assert fetch_attempts ["count" ] == 1
32473278
32483279
3280+ def test_wait_for_job_result_does_not_retry_executor_shutdown_fetch_errors ():
3281+ fetch_attempts = {"count" : 0 }
3282+
3283+ def fetch_result () -> dict :
3284+ fetch_attempts ["count" ] += 1
3285+ raise RuntimeError ("cannot schedule new futures after shutdown" )
3286+
3287+ with pytest .raises (
3288+ RuntimeError , match = "cannot schedule new futures after shutdown"
3289+ ):
3290+ wait_for_job_result (
3291+ operation_name = "sync wait helper fetch executor-shutdown" ,
3292+ get_status = lambda : "completed" ,
3293+ is_terminal_status = lambda value : value == "completed" ,
3294+ fetch_result = fetch_result ,
3295+ poll_interval_seconds = 0.0001 ,
3296+ max_wait_seconds = 1.0 ,
3297+ max_status_failures = 5 ,
3298+ fetch_max_attempts = 5 ,
3299+ fetch_retry_delay_seconds = 0.0001 ,
3300+ )
3301+
3302+ assert fetch_attempts ["count" ] == 1
3303+
3304+
32493305def test_wait_for_job_result_does_not_retry_timeout_fetch_errors ():
32503306 fetch_attempts = {"count" : 0 }
32513307
@@ -3568,6 +3624,40 @@ async def fetch_result() -> dict:
35683624 asyncio .run (run ())
35693625
35703626
3627+ def test_wait_for_job_result_async_does_not_retry_executor_shutdown_status_errors ():
3628+ async def run () -> None :
3629+ status_attempts = {"count" : 0 }
3630+ fetch_attempts = {"count" : 0 }
3631+
3632+ async def get_status () -> str :
3633+ status_attempts ["count" ] += 1
3634+ raise RuntimeError ("cannot schedule new futures after shutdown" )
3635+
3636+ async def fetch_result () -> dict :
3637+ fetch_attempts ["count" ] += 1
3638+ return {"ok" : True }
3639+
3640+ with pytest .raises (
3641+ RuntimeError , match = "cannot schedule new futures after shutdown"
3642+ ):
3643+ await wait_for_job_result_async (
3644+ operation_name = "async wait helper status executor-shutdown" ,
3645+ get_status = get_status ,
3646+ is_terminal_status = lambda value : value == "completed" ,
3647+ fetch_result = fetch_result ,
3648+ poll_interval_seconds = 0.0001 ,
3649+ max_wait_seconds = 1.0 ,
3650+ max_status_failures = 5 ,
3651+ fetch_max_attempts = 5 ,
3652+ fetch_retry_delay_seconds = 0.0001 ,
3653+ )
3654+
3655+ assert status_attempts ["count" ] == 1
3656+ assert fetch_attempts ["count" ] == 0
3657+
3658+ asyncio .run (run ())
3659+
3660+
35713661def test_wait_for_job_result_async_does_not_retry_timeout_status_errors ():
35723662 async def run () -> None :
35733663 status_attempts = {"count" : 0 }
@@ -3821,6 +3911,34 @@ async def fetch_result() -> dict:
38213911 asyncio .run (run ())
38223912
38233913
3914+ def test_wait_for_job_result_async_does_not_retry_executor_shutdown_fetch_errors ():
3915+ async def run () -> None :
3916+ fetch_attempts = {"count" : 0 }
3917+
3918+ async def fetch_result () -> dict :
3919+ fetch_attempts ["count" ] += 1
3920+ raise RuntimeError ("cannot schedule new futures after shutdown" )
3921+
3922+ with pytest .raises (
3923+ RuntimeError , match = "cannot schedule new futures after shutdown"
3924+ ):
3925+ await wait_for_job_result_async (
3926+ operation_name = "async wait helper fetch executor-shutdown" ,
3927+ get_status = lambda : asyncio .sleep (0 , result = "completed" ),
3928+ is_terminal_status = lambda value : value == "completed" ,
3929+ fetch_result = fetch_result ,
3930+ poll_interval_seconds = 0.0001 ,
3931+ max_wait_seconds = 1.0 ,
3932+ max_status_failures = 5 ,
3933+ fetch_max_attempts = 5 ,
3934+ fetch_retry_delay_seconds = 0.0001 ,
3935+ )
3936+
3937+ assert fetch_attempts ["count" ] == 1
3938+
3939+ asyncio .run (run ())
3940+
3941+
38243942def test_wait_for_job_result_async_does_not_retry_timeout_fetch_errors ():
38253943 async def run () -> None :
38263944 fetch_attempts = {"count" : 0 }
0 commit comments