@@ -6990,3 +6990,34 @@ async def test_update_handler_semaphore_acquisition_respects_timeout(
6990
6990
ever_in_critical_section = 3 , peak_in_critical_section = 3
6991
6991
),
6992
6992
)
6993
+
6994
+ @workflow .defn
6995
+ class TimeoutErrorWorkflow :
6996
+ @workflow .run
6997
+ async def run (self , scenario ) -> None :
6998
+ if scenario == "workflow.wait_condition" :
6999
+ await workflow .wait_condition (lambda : False , timeout = 0.01 )
7000
+ elif scenario == "asyncio.wait_for" :
7001
+ await asyncio .wait_for (asyncio .sleep (1000 ), timeout = 0.01 )
7002
+ elif scenario == "asyncio.timeout" :
7003
+ async with asyncio .timeout (0.1 ):
7004
+ await asyncio .sleep (1000 )
7005
+ else :
7006
+ raise RuntimeError ("Unrecognized scenario" )
7007
+
7008
+ async def test_workflow_timeout_error (client : Client ):
7009
+ async with new_worker (client , TimeoutErrorWorkflow ) as worker :
7010
+ scenarios = ["workflow.wait_condition" , "asyncio.wait_for" ]
7011
+ if sys .version_info >= (3 , 11 ):
7012
+ scenarios .append ("asyncio.timeout" )
7013
+
7014
+ for scenario in scenarios :
7015
+ with pytest .raises (WorkflowFailureError ) as err :
7016
+ await client .execute_workflow (
7017
+ TimeoutErrorWorkflow .run ,
7018
+ scenario ,
7019
+ id = f"workflow-{ uuid .uuid4 ()} " ,
7020
+ task_queue = worker .task_queue ,
7021
+ )
7022
+ assert isinstance (err .value .cause , ApplicationError )
7023
+ assert err .value .cause .type == "TimeoutError"
0 commit comments