Triggers & operationsReference

Run a step again later — without holding a machine

A loop that sleeps and checks again keeps a machine busy doing nothing. Return reschedule(...) instead: the step ends without an error, its slot goes to other work, and Waiso runs the same step again later. In a flow, the steps before it are not run again and their outputs stay as they were.

What you will learn
  • Reschedule a step from code in any language
  • Wait for another run or a key to be free, without checking again and again
  • See, run now or cancel a rescheduled run on the Runs page, the API or the MCP
  • Know what is kept and what is read again when the step resumes

Reschedule instead of waiting

Return what reschedule gives from main. Give exactly one of: in seconds, at a time (an ISO date and time; one already past runs at once), until a run finishes (a run or flow run id) or until a key is free. The last two wake at the latest after a ceiling (one hour unless you set it). Never more than 30 days ahead.

lock.py
import waiso

def main(rpi: int, scoped: bool = False):
    if scoped and general_generation_running(rpi):
        # Ends this step now; it runs again in 2 minutes with the same inputs.
        return waiso.reschedule(in_seconds=120, message=f"Waiting for the general generation of RPI {rpi}")
    print("attempt", waiso.run.context().rescheduled_count + 1)
    return {"rpi": rpi, "locked": True}

def general_generation_running(rpi: int) -> bool:
    return False
RunsEvery script and flow run in this project
Live
Search name or value · amount>100Ctrl KToday7 days30 daysAll time
Kind: AllStatus: AllWaiting for you 1
campaignFlowTriggered byScheduleDuration713msRan at5 h agoStatusSuccess
load_customersstep 1 of campaignTriggered bycampaignDuration38msRan at5 h agoStatusSuccess
send_offer ×4step 2 · loopTriggered bycampaignDuration188msRan at5 h agoStatusSuccess
approvalFlowTriggered byana@shop.devDuration174msRan at5 h agoStatusWaiting
report.pyTriggered byScheduleDuration6.7sRan at4 h agoStatusSuccess
broken.pyTriggered byana@shop.devDuration877msRan at26 min agoStatusFailed
The Runs page: a rescheduled run reads “Rescheduled — resumes at …” with the script’s message

What is kept, what is read again

Kept as on the first attemptRead again at resume
Inputs from earlier steps and the flow’s parametersVariables and secrets (a rotated token gives the new value)
The outputs of the steps before it, and the flow’s stateThe environment the code reads
The flow version the run started with (a new publish does not change it)—
  • Inside a loop or parallel branches, only that pass waits: the others go on, and the loop ends when the waiting passes come back and finish.
  • A subflow that reschedules makes its parent wait — without a machine either. Inside a loop or parallel branches it is that pass that waits: the other passes go on, and when the time comes the pass asks the same subflow run again, it never starts another.
  • Waiting never counts toward the step’s timeout and costs no credit; each attempt counts as one step run.
  • A step may reschedule itself 100 times per run; then it fails with reschedule_limit.

Wait for another run, or a key

Instead of waking every couple of minutes to check, wait for the run itself: the step wakes as soon as that run ends, or at the ceiling. With lockKey it wakes when the key — per project — is free.

wait_for_run.py
import waiso

def main(holder_flow_run_id: str):
    # Wakes as soon as that run ends (any final state) - or after an hour at the latest.
    return waiso.reschedule(until_run_finishes=holder_flow_run_id, ceiling_seconds=3600,
                            message="Waiting for the general generation to finish")

Take a lock first: wait_for

wait_for takes a lock of the project, or checks that a run has ended. It gives nothing when the step may go on — the lock is then yours until this run ends — and otherwise the reschedule request to return. C, C++, Bash, PHP and Ruby have it too (waiso_wait_for, waiso::waitFor, Waiso::waitFor, Waiso.wait_for). A run of another project counts only if you may read it; otherwise the error is run_not_found.

one_validation.py
import waiso

def main(rpi: int):
    # The lock is yours until this run ends; held by another run = wait without a machine.
    w = waiso.wait_for(lock_key=f"validation:{rpi}", message=f"Another validation of RPI {rpi} is running")
    if w:
        return w
    return validate(rpi)

One run at a time per key, and priority

In the item’s Triggers tab, under Limits, One run at a time per… takes the inputs whose values make the key — say rpiId, mode. Runs with the same values never run together; Runs at the same time sets how many per key (one when empty). Queue makes the others wait their turn without holding a machine; Refuse answers 409 concurrency_key_busy with the run that holds the key. A run missing one of those inputs is refused with concurrency_key_missing, and one that waits longer than Longest wait fails with concurrency_key_timeout, naming the holder. A flow that is waiting keeps its key.

Priority (Low, Normal, High) decides which queued runs start first, within your plan. A run that waits moves up one step every 10 minutes, so low priority never waits forever. A flow’s steps take the flow’s priority. For a flow, Time waiting counts toward the timeout makes the time spent waiting (rescheduled steps, approvals, pauses) count; off by default.

  • From the MCP: update_script and update_flow take priority and concurrencyKey ({inputs, mode, waitSecs}, null = off); a flow file carries them at the top, beside timeoutMs.
  • On the hosted service these settings come with the paid plans.

See it and steer it

On the Runs page a script run that waits reads Rescheduled — resumes at … in your time zone, with the script’s message, and the Rescheduled filter lists them. A flow reads running while any step still runs and waiting once only rescheduled steps remain. In a run’s panel, Run now runs it at once and Cancel ends it.

From the API and the MCP

  • POST /api/runs/{id}/reschedule with at or inSeconds and a message — a queued or rescheduled run, or a waiting flow run, runs later (the last request wins).
  • POST /api/runs/{id}/resume-now and POST /api/runs/{id}/cancel-reschedule.
  • MCP tools reschedule_run, resume_now and cancel_reschedule; get_run, get_flow_run and list_runs carry resumeAt, rescheduleMessage, rescheduledBy and rescheduleCount.
  • A synchronous endpoint whose run reschedules answers at once 202 with status: "rescheduled", resumeAt and the message; read the result later through the async poll.