Force one job at a time

I want to force a workflow (and the sub workflows it invokes) to run one at a time.

The nature of the workflow's triggering causes dozens to run simultaneously, which hits the Open AI rate limit and results in a bunch of incomplete jobs. (It's a QA operator going through an admin dashboard.)

I need a queue type system to enforce one at a time, but I'm pretty sure workflows don't support this natively.

Edit:
Seeing we can access the lastRun property off the global workflowContext variable. Can do something naive like set a timeout of x seconds after the last run... Lmk what yall think!
https://docs.retool.com/reference/workflows/global/workflowcontext

You could do that or you could push the inputs into a DB table and set it up as a queue? Capture the call via webhook, store it, and then have another workflow that runs every X minutes query the table and process each call sequentially with whatever queuing makes sense for your rate limits. You could store something in the DB to indicate the workflow is running (update the row with a flag) so if another instance of the workflow is triggered while the first is running, it first checks of any columns are flagged as running, if so, exit, if not, process the queue.

1 Like