<@ULVA73B9P> When my flow run fails, for some reas...
# ask-marvin
j
@Marvin When my flow run fails, for some reason the running time is still being tracked. How can I stop this?
m
In Prefect 3.x, if your flow run continues to track running time even after a failure, it might be due to the flow state not being updated correctly. Here are some steps you can consider: 1. State Management: Ensure that the state of the flow is properly transitioned to a failure state when an exception occurs. You can use
exception_to_failed_state
to handle exceptions and transition the flow to a failed state. 2. Timeout Handling: Implementing a timeout can help in preventing long-running tasks from continuing indefinitely. You can use
timeout
or
timeout_async
utilities from Prefect to set time limits on your tasks or flows. 3. Flow Run Management: Utilize methods like
propose_state
or
propose_state_sync
to explicitly set the state of a flow run when you detect a failure. This can help in ensuring that the flow does not remain in a running state. 4. Logging and Monitoring: Use Prefect's logging capabilities to monitor the state transitions and identify if there's a point where the state is not being updated as expected. For more detailed information, you can explore Prefect's flow engine code or refer to the documentation on handling flow states and exceptions: - Prefect Flow Engine Code If these steps don't resolve your issue, it might be worth checking if there are any additional configurations or custom logic in your flow that might interfere with the state transitions.