You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 56a09ad
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/features/configuration.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,9 @@ call retains the settings it started with. A watched policy changes behaviour
50
50
on every replica without a restart, for example to lower a rate limit or stop retries for one
51
51
dependency during an incident. See [named policies](resilience/named-policies.md).
52
52
53
-
A policy watch accepts `strict=True` to raise on a failed initial read or invalid mapping. Use `jitter=0.1` to vary the poll interval by up to 10 percent in either direction.
53
+
A policy watch raises on a failed first read or invalid mapping by default. Pass `strict=False`
54
+
to keep polling after a failed initial load. Use `jitter=0.1` to vary the poll interval by up
Copy file name to clipboardExpand all lines: docs/features/resilience/presets-and-doctor.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -156,7 +156,7 @@ The doctor reports codes PW001 to PW025 (the table lists them by group, not stri
156
156
| PW023 | warning |`python_wrap.celery.check_visibility`: a blocking limiter, unbounded bulkhead queue, retry `max_time`, or an `idempotent_task` lease (`lease_ttl`) can outlive the broker's visibility timeout, so the broker delivers the task again while it still runs (for a lease: a redelivery finds the lease held and is re-queued until it expires). |
157
157
| PW024 | warning | A retry layer has no backoff or jitter (`backoff=1` or no `jitter`): callers that fail together retry together, and with `--multiprocess` every worker does. Use `backoff=2, jitter="full"`. |
158
158
| PW025 | warning | A retry on every `Exception` with neither `retry_if=` nor `retry_if_result=`: programming errors and non-transient failures are retried. Narrow `on=` or add a predicate. Fires together with PW003, which also covers a broad `on=` with only `retry_if_result=`. |
159
-
| PW026 | warning |`memoize` with a shared store that uses plain pickle (the implicit default, or `pickle.dumps`): anyone who can write the namespace can run code in every reader. Pass `dumps=`/`loads=` (for example `json_codec()`) or `configure(cache_codec="json")`. See [Shared caches](../caching/stores-and-credentials.md#codecs). |
159
+
| PW026 | warning |`memoize` with a shared store that uses plain pickle: anyone who can write the namespace can run code in every reader. Use `json_codec()` or `configure(cache_codec="json")`. See [Shared caches](../caching/stores-and-credentials.md#codecs). |
160
160
| PW018 | warning | A python-wrap LLM retry wraps an SDK client (`llm_retry(client=...)`) whose own retries are still on: attempts multiply (4 x 3 = 12). See [OpenAI and Anthropic SDK clients](../ai/openai-anthropic.md#doctor-checks). |
161
161
| PW019 | warning | A retry wraps a streamed LLM call (`stream_timeout`) without `resume_safe`: a replay after output started repeats text and half-done tool calls. |
Copy file name to clipboardExpand all lines: docs/features/resilience/retry.md
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,8 +46,11 @@ For several workers, set a project default before decorating functions:
46
46
chooses between half and all of it. A numeric jitter still adds up to that many
47
47
seconds.
48
48
49
-
!!! warning "Bare `@retry` defaults change in 0.5.0"
50
-
A bare `@retry` (or `retrying()`) with no `delay`, `backoff` or `jitter` waits 1 s, three times, with no jitter. This release emits one `FutureWarning` per process saying so. In 0.5.0 the fallback becomes `backoff=2`, `jitter="equal"` and `max_delay=30`. To keep today's behaviour, pass `delay=`, `backoff=` or `jitter=` explicitly, or set the values with `configure(retry={...})`. An explicit `delays=` schedule does not warn. The `doctor` reports PW024 (no backoff or jitter) and PW025 (retries every `Exception` with no `retry_if=` or `retry_if_result=`) for such retries.
49
+
A bare `@retry` or `retrying()` uses exponential backoff and equal jitter. The first
50
+
retry waits 0.5 to 1 second, and the second waits 1 to 2 seconds. Scheduled backoff is
51
+
capped at 30 seconds. A server hint keeps its separate ceiling unless you set
52
+
`max_delay=` explicitly. Explicit `delays=` schedules keep their exact values unless
53
+
you configure a cap or jitter.
51
54
52
55
## When to use it
53
56
@@ -68,9 +71,9 @@ The wait before attempt `n + 1` is `min(delay * backoff ** (n - 1), max_delay) +
68
71
|`max_attempts`|`3`| Total calls allowed. `None` retries forever. |
69
72
|`delay`|`1.0`| Base wait in seconds. |
70
73
|`delays`|`None`| Explicit nonempty delay sequence; repeat the last entry. Overrides `delay`/`backoff`, with the same cap and jitter. |
71
-
|`backoff`|`1.0`| Multiplier applied after each failure (use `2` for exponential). |
72
-
|`max_delay`|`None`| Cap on the backoff wait (before jitter). |
73
-
|`jitter`|`0.0`|Up to this many random extra seconds, so many clients do not retry in lockstep. |
74
+
|`backoff`|`2.0`| Multiplier applied after each failure (use `2` for exponential). |
75
+
|`max_delay`|`30.0`| Cap on the backoff wait (before jitter). |
76
+
|`jitter`|`"equal"`|Choose between half and all of the capped wait. A numeric value adds up to that many seconds. |
74
77
|`max_time`|`None`| Total time budget in seconds from the first attempt. |
75
78
|`on`|`Exception`| Exception type(s) that trigger a retry. Anything else propagates immediately. |
76
79
|`retry_if`|`None`| Extra predicate on the exception; retry only if it returns `True`. May be `async def` for async functions. |
@@ -518,18 +521,16 @@ Sentry breadcrumbs so an error report shows what happened before the failure.
518
521
519
522
Set `max_attempts`, `delay`, `backoff`, `max_delay`, `jitter`, `max_time`, `log_level` and `budget` once for the whole project with `python_wrap.config.configure(retry={...})`. See [Configuration](../configuration.md).
520
523
521
-
To try the 0.5.0 timing defaults in a scoped block:
524
+
To restore the 0.4.x timing defaults in a scoped block:
522
525
523
526
```python
524
527
from python_wrap.config import configured
525
528
526
-
with configured(retry={"backoff": 2, "jitter": "equal", "max_delay": 30}):
529
+
with configured(retry={"backoff": 1, "jitter": 0, "max_delay": None}):
527
530
# Decorate functions here to use these defaults.
528
531
...
529
532
```
530
533
531
-
Setting any of `delay`, `backoff` or `jitter` here also silences the default-change warning.
532
-
533
534
## Logging
534
535
535
536
Each retry logs one message at `log_level` (default `WARNING`) on `logger`. Use `log_level=logging.INFO` to quiet it, `log_level=None` to turn it off, and `log_exc_info=True` to attach the traceback.
0 commit comments