Skip to main content
Set how long tasks can run, wait in a queue, and retry.

Execution Timeouts

Use timeout=-1 to disable timeouts on functions and task queues. Endpoints are capped at 600 seconds, including when timeout is nonpositive. Use a task queue for longer jobs.

Pending-task Expiry

TaskPolicy(ttl=...) limits how long a task may remain pending. Defaults are 12 hours for functions and scheduled jobs, 2 hours for task queues, and 600 seconds for endpoints. The gateway caps an explicitly configured TTL at 24 hours.
Client and proxy timeouts apply separately.

Waiting for Capacity

When a call doesn’t land on a warm machine, the CLI and SDK print what it’s waiting for, and again whenever that changes: If no machine becomes available within 20 minutes, the call fails with No capacity became available in 20 minutes. and suggestions, and the task’s failure reason says the same. TaskPolicy(ttl=...) doesn’t shorten this wait. To give up sooner, set BEAM_CAPACITY_WAIT to a number of seconds or a duration such as 90s or 5m. A function call that goes that long without a machine is cancelled, the function doesn’t run, and the command exits with status 1. With --json output, the error has code: CAPACITY.
In an interactive terminal, a function call that has waited 60 seconds for capacity asks once whether to keep waiting, reserve a machine (for GPU calls), or cancel. Elsewhere, it prints the options once and keeps waiting. The wait limit and prompt apply to function calls, not to Pods, sandboxes, or beam serve. While a task waits, the dashboard’s task view, the workspace REST API, and the MCP get_task tool show what it’s waiting for, in a pending object with phase, reason, waited_seconds, and message.

Retries

Functions, schedules, and task queues default to 3 retries. Configure retries on the decorator; the gateway caps retries at 5. Endpoint and ASGI requests have automatic task retries disabled. A task queue can retry selected exceptions with retry_for:
Make retried tasks safe to run more than once. retry_for is only available on task queues. Nonzero TaskPolicy.timeout and max_retries override the decorator; zero uses its settings. Set retries=0 on the decorator to disable retries.

Container Lifetime

keep_warm_seconds controls how long idle containers stay running. For sandboxes, it sets the sandbox lifetime. Neither setting is a task execution timeout.