Hello. I have a flow that calls 3 other subflows. ...
# ask-community
m
Hello. I have a flow that calls 3 other subflows. These subflows can enter
Cancelled
state in certain conditions (expected behavior). When any of them enters
Cancelled
state and the rest complete, the main flow also enters
Canceled
state. How can I make the main flow succeed? This is my code
Copy code
@flow()
def main_flow():
  subflows = (subflow1, subflow2, subflow3)  
    for subflow in subflows:
      try:
        subflow()
      except CancelledRun:
        continue
When the first flow cancels, I get something like this
Finished in state Cancelled('1/3 states cancelled.')
and the main flow state becomes Cancelled too. Thanks
For more context, the subflows Cancel their run using this mechanism:
Copy code
@task
def my_task():
  if condition:
    return Cancelled()
@flow
def subflow():
  my_task()
Is there a better way to do it?
facepalm I think I simply need to do
Copy code
for subflow in subflows:
      try:
        subflow()
      except CancelledRun:
        continue
      except Exception as e:
        ...
else:
  Completed()
👍 1
d
Well did that work? 😄
m
Yes it works