@@ -1220,6 +1220,26 @@ def operation() -> str:
12201220 assert attempts ["count" ] == 1
12211221
12221222
1223+ def test_retry_operation_does_not_retry_runtime_errors_for_non_thread_safe_loop_operation ():
1224+ attempts = {"count" : 0 }
1225+
1226+ def operation () -> str :
1227+ attempts ["count" ] += 1
1228+ raise RuntimeError (
1229+ "Non-thread-safe operation invoked on an event loop other than the current one"
1230+ )
1231+
1232+ with pytest .raises (RuntimeError , match = "event loop other than the current one" ):
1233+ retry_operation (
1234+ operation_name = "sync retry non-thread-safe loop runtime error" ,
1235+ operation = operation ,
1236+ max_attempts = 5 ,
1237+ retry_delay_seconds = 0.0001 ,
1238+ )
1239+
1240+ assert attempts ["count" ] == 1
1241+
1242+
12231243def test_poll_until_terminal_status_async_does_not_retry_runtime_errors_for_closed_loop ():
12241244 async def run () -> None :
12251245 attempts = {"count" : 0 }
@@ -1243,6 +1263,31 @@ async def get_status() -> str:
12431263 asyncio .run (run ())
12441264
12451265
1266+ def test_poll_until_terminal_status_async_does_not_retry_runtime_errors_for_non_thread_safe_loop_operation ():
1267+ async def run () -> None :
1268+ attempts = {"count" : 0 }
1269+
1270+ async def get_status () -> str :
1271+ attempts ["count" ] += 1
1272+ raise RuntimeError (
1273+ "Non-thread-safe operation invoked on an event loop other than the current one"
1274+ )
1275+
1276+ with pytest .raises (RuntimeError , match = "event loop other than the current one" ):
1277+ await poll_until_terminal_status_async (
1278+ operation_name = "async poll non-thread-safe loop runtime error" ,
1279+ get_status = get_status ,
1280+ is_terminal_status = lambda value : value == "completed" ,
1281+ poll_interval_seconds = 0.0001 ,
1282+ max_wait_seconds = 1.0 ,
1283+ max_status_failures = 5 ,
1284+ )
1285+
1286+ assert attempts ["count" ] == 1
1287+
1288+ asyncio .run (run ())
1289+
1290+
12461291def test_poll_until_terminal_status_async_does_not_retry_runtime_errors_for_event_loop_binding ():
12471292 async def run () -> None :
12481293 attempts = {"count" : 0 }
0 commit comments