工作流程流动

wait()

run.wait({ until?, timeoutMs?, intervalMs? }) → Promise<WorkflowRun>

运行到到达您命名的状态之一时, 运行将一直持续到运行。 默认情况下, 包括等待 —— 因为人类的运行停止后, 运行不会继续运行 。

10 minutesevery 2 secondswaiting counts as arrived
Using Python?

Switch any code block to Python: the choice applies to every page. Python SDK guide and resource reference.

untilstring[]["waiting", "succeeded", "failed", "cancelled"]

哪个状态结束等待。

timeoutMsinteger600 000

十分钟过去 timeout 扔了408个。

intervalMsinteger2 000

读了多少次

await run.wait();

if (run.data.status === "waiting") {
  const step = run.data.steps.find((s) => s.status === "waiting");
  await run.resume(step.id, { approved: true });
  await run.wait();                       // then on to the end
}
run.wait()

if run.data["status"] == "waiting":
    step = next(s for s in run.data["steps"] if s["status"] == "waiting")
    run.resume(step["id"], {"approved": True})
    run.wait()                       # then on to the end

为什么等待是在默认时间

人类一步一步 等待无休无止

默认的等待将最终总是在批准后超时任何工作流程中结束,而超时看起来将是一个失败。 将“停止某人入境”视为“抵达”是导致默认违约有用的原因。

等待最后

await run.wait({ until: ["succeeded", "failed", "cancelled"], timeoutMs: 30 * 60_000 });
run.wait(until=["succeeded", "failed", "cancelled"], timeout_ms=30 * 60_000)

合理时,当有其他事情批准人的步骤。 提高上限, 链条只要得到人的认可, 就可以持续多久。

超时不会停止运行

扔着 timeout 继续跑 接住 晚点再来 raun() -或打电话 (取消) 如果你是想阻止的话

import { IaGenifyError } from "iagenify";

try {
  await run.wait({ timeoutMs: 60_000 });
} catch (err) {
  if (err instanceof IaGenifyError && err.code === "timeout") {
    // Still running. Keep run.id and come back.
  } else throw err;
}
from iagenify import IaGenifyError

try:
    run.wait(timeout_ms=60_000)
except IaGenifyError as error:
    if error.code != "timeout":
        raise
    # Still running. Keep run.id and come back.

投票是自由的,但不是即时

每个滴子都是读取,读取成本不高。 较短的间隔反应更快, 要求更多, 选择的平衡为两秒。