Hi is there a way to clear work queues? I can see ...
# prefect-community
d
Hi is there a way to clear work queues? I can see a method to delete but not to clear. Have had instance where a agents polling the queue were down for quite a while and runs built up. I would like to be able to clear any delayed runs rather than having them all play through.
a
I don't believe so. Apparently it was a feature in Prefect 1, has not been added to 2 yet. I've had the same issue where a long running flow run queued up dozens of late ones
d
Hey thanks Aaron. I’m finding a lot of features which were useful in v1 which have been dropped.
a
My workaround has been to use separate work queues. I have a flow that runs every few minutes, and issues with other flows could cause a bunch of those to get queued up with "Late" status, and then all of those Late runs would still run once the stalled flow finished.
n
I agree it'd be nice to have a first class way of doing this, but for the time being you can always do something like
Copy code
from prefect.client import get_client()

async with get_client() as client:
   try:
      runs = await client.get_runs_in_work_queue("<MY-QUEUE-UUID>")
      for run in runs:
         await client.delete_flow_run(flow_run_id=run.id)
d
Nice suggestion @Nate thanks