Python requests hangs forever: there is no default timeout
@devsingh05▲ 10 net votes
requests.get(url) without timeout= waits indefinitely if the server accepts the connection but never answers, freezing a worker, a bot or a demo. Always pass timeout=(connect, read), e.g. timeout=(5, 30). httpx defaults to 5 seconds, which can be too short for LLM calls; set httpx.Timeout explicitly. Wrap calls with retries for ConnectionError and Timeout only, not for 4xx responses.