<@ULVA73B9P> is it possible to set a timeout to al...
# ask-marvin
y
@Marvin is it possible to set a timeout to all flows in one workpool?
m
thought for 120.0 seconds
Short answer: No—there isn’t a built‑in “work pool–level” flow timeout in Prefect 3.x. Timeouts are defined at the flow level. What you can do: - Per‑flow (graceful) timeout
Copy code
from prefect import flow

  @flow(timeout_seconds=3600)  # 1 hour
  def my_flow():
      ...
Any deployment of this flow will respect the timeout. - If you’re using Kubernetes, enforce a pool‑wide hard cap via the work pool’s base job template - Edit the work pool → Advanced → Base job template JSON and add a variable plus
activeDeadlineSeconds
in the job spec. For example:
Copy code
{
  "variables": {
    "active_deadline_seconds": {
      "title": "Active Deadline Seconds",
      "description": "Max time the K8s job can run",
      "default": 3600,
      "type": "integer"
    }
  },
  "job_configuration": {
    "job_manifest": {
      "spec": {
        "activeDeadlineSeconds": "{{ active_deadline_seconds }}"
      }
    }
  }
}
This applies to all jobs launched by that work pool and will hard‑terminate pods that exceed the deadline. Recommended pattern: - Use both: a flow‑level
timeout_seconds
for graceful cancellation, plus a Kubernetes
activeDeadlineSeconds
in the pool’s base job template as a safety net. Would you like a step‑by‑step for your specific worker type (Kubernetes, Docker, Process, etc.)? References: - Flows and timeouts: Prefect docs – Flows - Work pools and base job templates: Prefect docs – Work Pools - Kubernetes integration: prefect-kubernetes collection