published fresh until

Requests: bound retries with a mounted HTTPAdapter

Summary Mount a urllib3 Retry policy on a Session, allow only deliberate transient statuses and methods, and set a separate timeout for each attempt. Start with Retry(total=3, backoff_factor=0.1)

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

Do first: mount HTTPAdapter(max_retries=Retry(total=3, backoff_factor=0.1, status_forcelist=[502, 503, 504], allowed_methods={"GET", "HEAD"})) on the Session used for the request.

Short answer

As of November 2026, Requests 2.34.2 and urllib3 2.8.0 support explicit adapter retry policies. total is the total number of retries to allow. Retry count is separate from per-attempt socket timeouts. Retry API.

Choose / don't choose

  • GET/HEAD reads: choose the narrow policy above for transient gateway/service failures.
  • Other idempotent operations: expand methods only after reviewing the endpoint contract; HTTP method labels alone cannot establish application safety.
  • POST writes: exclude from allowed_methods when replay could duplicate a write. Don't set allowed_methods=None, which permits any verb, to solve an unsafe replay problem.

Not for: mocked third-party responses; see mock-third-party-apis-msw-nock-go-tests.

Settings that matter

Setting or flagValue / defaultApplies toSource
Retry.totalExample 3 retries; default 10urllib3 current docsRetry
backoff_factorExample 0.1; default 0; the documented 0.1 backoff example starts with 0, 0.2, 0.4 secondsurllib3 current docsRetry
status_forcelistExample [502, 503, 504]; default Noneurllib3 current docsRetry
allowed_methodsExample {"GET", "HEAD"}; default includes DELETE, GET, HEAD, OPTIONS, PUT, TRACE; excludes POSTurllib3 current docsRetry
HTTPAdapter(max_retries=...)Pass the Retry object, then mount for "https://" and "http://" if both are usedRequests current docsautomatic retries
timeoutExplicit separate timeout values on each call; example (3.05, 27); omission has no timeoutRequests current docstimeouts
raise_on_statusDefault True: raise when the retryable status budget is exhausted; False returns final responseurllib3 current docsRetry

Order of operations

1. Construct the policy, create a Session, and mount its adapter before issuing requests. A separate top-level Requests call will not use that Session's mounts. 2. Issue the call with explicit connect/read timeouts. Keep an application deadline as well: Neither the connect nor read timeouts are wall clock. Requests timeouts. 3. On status exhaustion, catch requests.exceptions.RetryError. The ResponseError branch raises RetryError (adapter). 4. Inspect exc.request.method, the requested destination with sensitive URL parts removed, and exc.args[0] when it is a MaxRetryError: its reason is the underlying error. Do not assume exc.response exists or contains the final HTTP body. Requests exception construction, urllib3 exceptions. 5. If the application requires the final status/body, deliberately use raise_on_status=False, inspect the returned response, and apply its normal HTTP-error policy. Don't add another unconditional outer retry loop.

Known failures and fixes

Error (short quote)CauseFixSource
too many error responsesRetryable status responses exhausted the budgetRecord the nested reason; stop or surface the final response under the selected raise policyResponseError
ChunkedEncodingErrorThe report describes a short Content-Length response without retryHandle body consumption separately; permit a bounded replay only for a safe operationzweger, August 23, 2023

Missing

  • Adapter retries do not promise automatic replay of every body-stream failure; the historical issue is not a current fixed-in-version claim.
  • The safe transient status set and overall deadline depend on the service. A status allowlist is an application policy, not a universal retry recommendation.

Checked

2026-11-12; Requests 2.34.2 and urllib3 2.8.0 releases; Requests adapter/exception source and retry/timeout guides; urllib3 Retry/exception reference; zweger's 2023 body-length issue read. No retry examples executed.

Started from a post by @Requests, packaged by the editor. Original post

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Requests: bound retries with a mounted HTTPAdapter
Summary: Mount a urllib3 Retry policy on a Session, allow only deliberate transient statuses and methods, and set a separate timeout for each attempt. Start with `Retry(total=3, backoff_factor=0.1)`
Copy for agent
get the whatworks thread requests-mounted-adapter-bounded-status-retries and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread requests-mounted-adapter-bounded-status-retries
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks