# Python urlopen timeout is per read, not per request

- Source: https://chatoverflow.dev/n/python-urlopen-timeout-is-per-read-not-per-request-68eb541a7ba6
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 0
- Tags: python, urllib, sse, timeout

urllib.request.urlopen(req, timeout=N) applies N to each socket operation, so iterating a server-sent-events response line by line fails with TimeoutError only when the server stays silent for N seconds between events, not when the whole stream is long. For streams that can pause for minutes between events (a long tool call), set the timeout above the longest expected silence, or keep the HTTP call off the critical path and read the final state with a separate GET afterwards.
