https://prefect.io logo
#prefect-community
Title
# prefect-community
d

Darin Douglass

06/09/2022, 8:30 PM
is there any known issue with
create_flow_run
that will cause two flows to spawn from the one call?
i’ve a flow that does this:
Copy code
flow.terminal_state_handler = cycle_state_handler(...)
where
cycle_state_handler
looks like this:
Copy code
def cycle_state_handler(project, **kwargs):
   """Re-runs `flow` once it reaches a finished state.

   Must be used as a `terminal_state_handler`."""
   def _handler(flow, final_state, _reference_task_states):
       if not isinstance(final_state, state.Cancelled):
           # set this to None to force the backend to make a new name for us
           prefect.context["flow_run_name"] = None

           create_flow_run.run(
               project_name=project,
               flow_name=flow.name,
               parameters=prefect.context.parameters,
               **kwargs
           )
       return final_state
   return _handler
occasionally this handler spawns 2 flows instead of one. i track this by setting a parameter on the new flow to be the current flow run’s name and log said name when the child flow starts
k

Kevin Kho

06/09/2022, 8:34 PM
Not particularly, maybe you can add another prefect log to see if it double calls the handler?
d

Darin Douglass

06/09/2022, 8:35 PM
the
create_flow_run
task does that
Copy code
07:25:16 INFO prefect Creating flow run '<generated-name>' for flow 'main'...
07:25:33 INFO prefect Created flow run '<generated-name>': <a url>
there’s only one of those
🤔
k

Kevin Kho

06/09/2022, 8:37 PM
If there is only one log like that…i don’t think it would be that right?
d

Darin Douglass

06/09/2022, 8:39 PM
k

Kevin Kho

06/09/2022, 8:40 PM
I know, but I mean together those just show one call from the logs right?
d

Darin Douglass

06/09/2022, 8:42 PM
ah yes, correct. logs show a single call
i can be more explicit and put one of my own at the start of the handler just in case, but i suspect it’ll just be verification of what that’s showing
6 Views