Skip to content

Commit

Permalink
Reinstate loop
Browse files Browse the repository at this point in the history
  • Loading branch information
dandavison committed Jul 24, 2024
1 parent 7ec0e72 commit e3eba6e
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions updates_and_signals/safe_message_handlers/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,18 @@ def should_continue_as_new(self) -> bool:
@workflow.run
async def run(self, input: ClusterManagerInput) -> ClusterManagerResult:
self.init(input)
await workflow.wait_condition(
lambda: self.state.cluster_shutdown or self.should_continue_as_new()
)
if self.should_continue_as_new():
workflow.logger.info("Continuing as new")
workflow.continue_as_new(
ClusterManagerInput(
state=self.state,
test_continue_as_new=input.test_continue_as_new,
)
while True:
await workflow.wait_condition(
lambda: self.state.cluster_shutdown or self.should_continue_as_new()
)
else:
return ClusterManagerResult(len(self.get_assigned_nodes()))
if self.state.cluster_shutdown:
break
if self.should_continue_as_new():
workflow.logger.info("Continuing as new")
workflow.continue_as_new(
ClusterManagerInput(
state=self.state,
test_continue_as_new=input.test_continue_as_new,
)
)
return ClusterManagerResult(len(self.get_assigned_nodes()))

0 comments on commit e3eba6e

Please sign in to comment.