Python requests default timeout: there isn't one
Python Requests has no default timeout: without timeout= a call can hang indefinitely. Set (connect, read) on every call, and keep it short for job APIs.

Python Requests has no default timeout. If you don't pass timeout=, Requests does not time out, and the call can hang indefinitely while it waits for a server that never answers. Pass timeout=(connect, read) on every call, for example timeout=(3.05, 27).
The Requests facts come from its own Quickstart, Advanced Usage and Developer Interface pages. The slow-API example is Sume's video generation API, from Jobs and results and Video Generation. All were read on 2026-09-29.
What is the default timeout in Python requests?
None. In the Developer Interface, timeout is an optional parameter whose default is None, and the Advanced Usage page says "requests do not time out unless a timeout value is set explicitly. Without a timeout, your code may hang for minutes or more." The Quickstart says nearly all production code should use this parameter in nearly all requests.
The same applies to requests.post, requests.get and calls made through a Session: each call takes its own timeout argument.
How do I set a timeout in requests?
Pass one number or a tuple. The table shows what each form does.
| You pass | What Requests does |
|---|---|
| Nothing | Doesn't time out |
timeout=5 | Applies 5 seconds to both the connect and the read timeout |
timeout=(3.05, 27) | 3.05 s to connect, 27 s to wait for the server to send data |
timeout=None | Waits forever for a response |
| Timed out while connecting | Raises ConnectTimeout, which the docs call safe to retry |
| Timed out waiting for data | Raises ReadTimeout; catching Timeout catches both |
What does the timeout actually measure?
Not the total time of the request. Four rules from the Requests docs:
- The read timeout is not a limit on the whole download. Requests raises an exception when no bytes arrive on the socket for that many seconds.
- Neither timeout is wall clock, so a request can run longer in real time than the number you set.
- The connect timeout applies to each connection attempt to an IP address. A host with both IPv4 and IPv6 addresses can double the time you wait to connect.
- Requests suggests a connect timeout slightly larger than a multiple of 3, the default TCP packet retransmission window.
What timeout should I use for a slow API?
Size the timeout to the HTTP response, not to the work. A video job can run for minutes, but Sume's create call, POST /v1/videos, answers at once with a job id and a polling_url; you poll that URL until the status is completed. Short timeouts on both calls are enough:
import os
import requests
auth = {"Authorization": f"Bearer {os.environ['SUME_API_KEY']}"}
body = {
"model": "sume/auto",
"prompt": "A vertical product clip on a desk, natural light",
"aspect_ratio": "9:16",
"duration": 5,
}
r = requests.post(
"https://api.sume.com/v1/videos",
json=body,
headers={**auth, "Idempotency-Key": "order-8823-clip-v1"},
timeout=(3.05, 30),
)
r.raise_for_status()
job = r.json() # id, polling_url, status "pending"
s = requests.get(job["polling_url"], headers=auth, timeout=(3.05, 10))
print(s.json()["status"])What happens to the job when requests times out?
A client-side timeout does not cancel the job: it keeps running and still bills, as Text-to-video API in Python also notes with the full submit, poll and download script.
If the create itself raised ReadTimeout, you can't tell whether the job was made. Resend it with the same Idempotency-Key and the same body: on /v1/videos, a replay returns the original job. Without a key, Sume's docs say not to retry an unsafe submit at all. Requests itself does not retry failed connections by default; Python requests retry shows a retry policy with backoff.
Sources
Related posts
More in Developers
- Real time speech to text API: what a file-based API can do
Sume's speech to text API isn't real time: it transcribes recordings of up to 10 minutes at a URL. Chunked recordings give near-live transcripts.
- Extract on-screen text from a reference video with an API
Reference ingest reads on-screen text at source resolution, returns lines with boxes, spans and confidence, and flags low-confidence lines instead of guessing.
- Reference video shot breakdown API: cuts, keyframes and timings
Break a reference video into shots with an API: POST /v1/reference-ingest returns frame-exact cuts, keyframes and a labeled strip for one clip, unbilled.
- Check whether a reference video is silent before adding music
Reference ingest reports audio.silent at a -60 LUFS gate, speech presence and beats, so you know whether to keep, replace or add a soundtrack before a remix.
Written by Sume