@@ -2946,12 +2946,21 @@ async def waiting_signal() -> bool:
29462946 task_queue = task_queue ,
29472947 )
29482948
2949+ # Need to wait until it has gotten halfway through, otherwise the post_patch workflow may never complete
2950+ async def waiting_signal () -> bool :
2951+ return await post_patch_handle .query (
2952+ PatchMemoizedWorkflowPatched .waiting_signal
2953+ )
2954+
2955+ await assert_eq_eventually (True , waiting_signal )
2956+
29492957 # Send signal to both and check results
29502958 await pre_patch_handle .signal (PatchMemoizedWorkflowUnpatched .signal )
29512959 await post_patch_handle .signal (PatchMemoizedWorkflowPatched .signal )
29522960
29532961 # Confirm expected values
29542962 assert ["some-value" ] == await pre_patch_handle .result ()
2963+
29552964 assert [
29562965 "pre-patch" ,
29572966 "some-value" ,
@@ -6091,22 +6100,21 @@ def __init__(
60916100 self .main_workflow_returns_before_signal_completions = (
60926101 main_workflow_returns_before_signal_completions
60936102 )
6094- self .ping_pong_val = 1
6095- self .ping_pong_counter = 0
6096- self .ping_pong_max_count = 4
6103+ self .run_finished = False
60976104
60986105 @workflow .run
60996106 async def run (self ) -> str :
61006107 await workflow .wait_condition (
61016108 lambda : self .seen_first_signal and self .seen_second_signal
61026109 )
6110+ self .run_finished = True
61036111 return "workflow-result"
61046112
61056113 @workflow .signal
61066114 async def this_signal_executes_first (self ):
61076115 self .seen_first_signal = True
61086116 if self .main_workflow_returns_before_signal_completions :
6109- await self . ping_pong (lambda : self .ping_pong_val > 0 )
6117+ await workflow . wait_condition (lambda : self .run_finished )
61106118 raise ApplicationError (
61116119 "Client should see this error unless doing ping-pong "
61126120 "(in which case main coroutine returns first)"
@@ -6117,18 +6125,12 @@ async def this_signal_executes_second(self):
61176125 await workflow .wait_condition (lambda : self .seen_first_signal )
61186126 self .seen_second_signal = True
61196127 if self .main_workflow_returns_before_signal_completions :
6120- await self . ping_pong (lambda : self .ping_pong_val < 0 )
6128+ await workflow . wait_condition (lambda : self .run_finished )
61216129 raise ApplicationError ("Client should never see this error!" )
61226130
6123- async def ping_pong (self , cond : Callable [[], bool ]):
6124- while self .ping_pong_counter < self .ping_pong_max_count :
6125- await workflow .wait_condition (cond )
6126- self .ping_pong_val = - self .ping_pong_val
6127- self .ping_pong_counter += 1
6128-
61296131
61306132@workflow .defn
6131- class FirstCompletionCommandIsHonoredPingPongWorkflow (
6133+ class FirstCompletionCommandIsHonoredSignalWaitWorkflow (
61326134 FirstCompletionCommandIsHonoredWorkflow
61336135):
61346136 def __init__ (self ) -> None :
@@ -6157,10 +6159,10 @@ async def _do_first_completion_command_is_honored_test(
61576159 client : Client , main_workflow_returns_before_signal_completions : bool
61586160):
61596161 workflow_cls : Union [
6160- Type [FirstCompletionCommandIsHonoredPingPongWorkflow ],
6162+ Type [FirstCompletionCommandIsHonoredSignalWaitWorkflow ],
61616163 Type [FirstCompletionCommandIsHonoredWorkflow ],
61626164 ] = (
6163- FirstCompletionCommandIsHonoredPingPongWorkflow
6165+ FirstCompletionCommandIsHonoredSignalWaitWorkflow
61646166 if main_workflow_returns_before_signal_completions
61656167 else FirstCompletionCommandIsHonoredWorkflow
61666168 )
0 commit comments