TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Advanced usage of Python requests: timeouts, retries, hooks

123 pointsby dhxtabout 5 years ago

6 comments

inetknghtabout 5 years ago
I just recently dealt with a timeout issue in requests: I was setting the timeout to 1 but it took 10 seconds for the request to fail. It turns out that the timeout <i>does not apply</i> to the name resolver and the name lookup was timing out. So the default system-level timeout was 10 seconds.
hmhrexabout 5 years ago
Thank you for this brief reference. I&#x27;m always going back to my old projects to remind myself how I did things with requests. I didn&#x27;t realize some of things existed.
评论 #22443832 未加载
sciurusabout 5 years ago
I wish that requests had a default timeout instead of defaulting to waiting forever.<p>It&#x27;s very easy for devs to forget to think about timeouts, but inevitably that ends in a cascading production outage.
评论 #22443905 未加载
jakeoghabout 5 years ago
If I enable logging of retries: logging.basicConfig(level=logging.DEBUG)<p>I dont see any retries on response 200: ConnectionError(ReadTimeoutError(&quot;HTTPSConnectionPool(host=&#x27;domain.com&#x27;, port=443): Read timed out.&quot;))<p>Is there a way to also retry on ChunkedEncodingError?
ddeokbokkiabout 5 years ago
That sentry responses decorator is absolutely beautiful
da12about 5 years ago
Fantastic reference. Thanks for sharing!