Lee
02/04/2025, 9:08 PMCANCEL_NEW
, but I'm having it call a task that sleeps for 5 minutes as a test. I expected that when the scheduler tried to trigger a new run while the old one was still going, it either wouldn't start it or would cancel it immediately. Instead, I ended up with an ever-increasing queue of waiting flow runs. Is this the expected behavior? If so, what is the intended usage of CANCEL_NEW
, and is there a way to avoid creating new scheduled runs if the previous run didn't finish as soon as expected?Bianca Hoch
02/04/2025, 9:20 PMCANCEL_NEW
collision strategy should cancel new runs that exceed the concurrency limit provided for a deployment (rather than queuing them). Once the limit is hit, the new runs should be cancelled immediately.Bianca Hoch
02/04/2025, 9:22 PMLee
02/04/2025, 9:32 PMLate
Bianca Hoch
02/04/2025, 9:38 PMCANCEL_NEW
?Bianca Hoch
02/04/2025, 9:38 PMLee
02/04/2025, 9:39 PMBianca Hoch
02/04/2025, 9:40 PMLee
02/04/2025, 9:41 PMBianca Hoch
02/04/2025, 9:43 PMLee
02/04/2025, 10:01 PMfrom prefect import flow
from time import sleep
@flow
def slow_flow():
sleep(90)
prefect.yaml:
# Welcome to your prefect.yaml file! You can use this file for storing and managing
# configuration for deploying your flows. We recommend committing this file to source
# control along with your flow code.
# Generic metadata about this project
name: slow_flow_test
# build section allows you to manage and build docker images
build: null
# push section allows you to manage if and how this project is uploaded to remote locations
push: null
# pull section allows you to provide instructions for cloning this project in remote locations
pull: null
# the deployments section allows you to provide configuration for deploying flows
deployments:
- name: "slow_flow"
entrypoint: flows.py:slow_flow
work_pool:
name: slow_flow_pool
schedule:
interval: 30
concurrency_limit:
limit: 1
collision_strategy: CANCEL_NEW
Then run something like this:
prefect server start &
sleep 10
export PREFECT_API_URL=<http://localhost:4200/api>
prefect work-pool create slow_flow_pool --type process
prefect work-pool set-concurrency-limit slow_flow_pool 1
prefect deploy --all
prefect worker start --pool slow_flow_pool --type process --limit 1 &
Lee
02/04/2025, 10:01 PMLee
02/04/2025, 10:04 PMLee
02/04/2025, 10:12 PMBianca Hoch
02/04/2025, 10:15 PMBianca Hoch
02/04/2025, 10:19 PMLee
02/04/2025, 10:21 PMBianca Hoch
02/05/2025, 5:28 PMBianca Hoch
02/05/2025, 5:29 PM