{
  "slug": "tenacity-callback-order",
  "version": 1,
  "project": "tenacity",
  "title": "Tenacity retry callback order",
  "description": "Tenacity runs before, then the attempted function. If the retry predicate accepts the outcome, after runs, wait computes the delay, and stop chooses exhaustion or before_sleep followed by sleep and the next attempt. An outcome not selected for retry returns or raises.",
  "config": {
    "design": "flowchart-top-down-diamonds-side-branches",
    "name": "callback-order",
    "style": "clean",
    "palette": [
      "#316d9c"
    ],
    "parameters": {
      "nodes": [
        {
          "id": "before",
          "label": "before: prepare attempt",
          "kind": "start"
        },
        {
          "id": "call",
          "label": "Call the function",
          "kind": "process"
        },
        {
          "id": "retry",
          "label": "Retry this outcome?",
          "kind": "decision"
        },
        {
          "id": "after",
          "label": "after: inspect outcome",
          "kind": "process"
        },
        {
          "id": "wait",
          "label": "wait: calculate delay",
          "kind": "process"
        },
        {
          "id": "stop",
          "label": "stop: limit reached?",
          "kind": "decision"
        },
        {
          "id": "before-sleep",
          "label": "before_sleep",
          "kind": "process"
        },
        {
          "id": "sleep",
          "label": "Sleep, then next attempt",
          "kind": "end"
        },
        {
          "id": "return",
          "label": "Return result or raise its exception",
          "kind": "end"
        },
        {
          "id": "exhausted",
          "label": "retry_error_callback or RetryError",
          "kind": "end"
        }
      ],
      "edges": [
        {
          "from": "before",
          "to": "call"
        },
        {
          "from": "call",
          "to": "retry"
        },
        {
          "from": "retry",
          "to": "after",
          "label": "Yes"
        },
        {
          "from": "retry",
          "to": "return",
          "label": "No"
        },
        {
          "from": "after",
          "to": "wait"
        },
        {
          "from": "wait",
          "to": "stop"
        },
        {
          "from": "stop",
          "to": "before-sleep",
          "label": "No"
        },
        {
          "from": "stop",
          "to": "exhausted",
          "label": "Yes"
        },
        {
          "from": "before-sleep",
          "to": "sleep"
        }
      ]
    },
    "accessibility": {
      "title": "Tenacity retry callback order",
      "description": "Tenacity runs before, then the attempted function. If the retry predicate accepts the outcome, after runs, wait computes the delay, and stop chooses exhaustion or before_sleep followed by sleep and the next attempt. An outcome not selected for retry returns or raises."
    }
  },
  "files": {
    "svg": {
      "url": "/diagram-sources/tenacity-callback-order/v1/diagram.svg",
      "sha256": "f283a9c403808478affa5f6d5287a71975e3beedf367c27bc0481972068232fe"
    },
    "png": {
      "url": "/diagram-sources/tenacity-callback-order/v1/diagram.png",
      "sha256": "0c7601b2d64adaf80f0c60f687c346c71b6e32b17da6202b1cfe7aceb232c5fd"
    }
  }
}
