@@ -6100,22 +6100,21 @@ def __init__(
6100
6100
self .main_workflow_returns_before_signal_completions = (
6101
6101
main_workflow_returns_before_signal_completions
6102
6102
)
6103
- self .ping_pong_val = 1
6104
- self .ping_pong_counter = 0
6105
- self .ping_pong_max_count = 4
6103
+ self .run_finished = False
6106
6104
6107
6105
@workflow .run
6108
6106
async def run (self ) -> str :
6109
6107
await workflow .wait_condition (
6110
6108
lambda : self .seen_first_signal and self .seen_second_signal
6111
6109
)
6110
+ self .run_finished = True
6112
6111
return "workflow-result"
6113
6112
6114
6113
@workflow .signal
6115
6114
async def this_signal_executes_first (self ):
6116
6115
self .seen_first_signal = True
6117
6116
if self .main_workflow_returns_before_signal_completions :
6118
- await self . ping_pong (lambda : self .ping_pong_val > 0 )
6117
+ await workflow . wait_condition (lambda : self .run_finished )
6119
6118
raise ApplicationError (
6120
6119
"Client should see this error unless doing ping-pong "
6121
6120
"(in which case main coroutine returns first)"
@@ -6126,18 +6125,12 @@ async def this_signal_executes_second(self):
6126
6125
await workflow .wait_condition (lambda : self .seen_first_signal )
6127
6126
self .seen_second_signal = True
6128
6127
if self .main_workflow_returns_before_signal_completions :
6129
- await self . ping_pong (lambda : self .ping_pong_val < 0 )
6128
+ await workflow . wait_condition (lambda : self .run_finished )
6130
6129
raise ApplicationError ("Client should never see this error!" )
6131
6130
6132
- async def ping_pong (self , cond : Callable [[], bool ]):
6133
- while self .ping_pong_counter < self .ping_pong_max_count :
6134
- await workflow .wait_condition (cond )
6135
- self .ping_pong_val = - self .ping_pong_val
6136
- self .ping_pong_counter += 1
6137
-
6138
6131
6139
6132
@workflow .defn
6140
- class FirstCompletionCommandIsHonoredPingPongWorkflow (
6133
+ class FirstCompletionCommandIsHonoredSignalWaitWorkflow (
6141
6134
FirstCompletionCommandIsHonoredWorkflow
6142
6135
):
6143
6136
def __init__ (self ) -> None :
@@ -6166,10 +6159,10 @@ async def _do_first_completion_command_is_honored_test(
6166
6159
client : Client , main_workflow_returns_before_signal_completions : bool
6167
6160
):
6168
6161
workflow_cls : Union [
6169
- Type [FirstCompletionCommandIsHonoredPingPongWorkflow ],
6162
+ Type [FirstCompletionCommandIsHonoredSignalWaitWorkflow ],
6170
6163
Type [FirstCompletionCommandIsHonoredWorkflow ],
6171
6164
] = (
6172
- FirstCompletionCommandIsHonoredPingPongWorkflow
6165
+ FirstCompletionCommandIsHonoredSignalWaitWorkflow
6173
6166
if main_workflow_returns_before_signal_completions
6174
6167
else FirstCompletionCommandIsHonoredWorkflow
6175
6168
)
0 commit comments