v1.2.1

Timeouts

Last updated


This page explains how a per-task execution limit and its timeout callback behave.

Setting a Limit


  1. _, err := c.Add("@every 1m", slowJob, "slow job", 3*time.Second, func() {
  2. log.Println("slow job timed out")
  3. })
  4. if err != nil {
  5. log.Fatal(err)
  6. }

The time.Duration argument is the execution limit, not a start delay; the func() argument is called only when that limit is exceeded.

Timeout Behavior


BehaviorDescription
Timer startWhen the action begins
On timeoutTask marked TaskFailed; timeout callback invoked
Action goroutineNot interrupted; runs until it returns
Panic with a limit setNot recovered: the action goroutine has no recover, so the process exits
No limit setAction runs synchronously until it returns; a panic is recovered and the task is marked TaskFailed
Timeout error texttask timeout: <limit in nanoseconds> for tasks without dependencies, task timeout <limit in nanoseconds> for dependent tasks

See Configuration for the full list of Add options.
中文