Proposal: Add a Global Timeout Setting in httpx #3356
Replies: 3 comments 11 replies
-
This is being actively discussed for v1.0 (e.g. #3344 (comment)) |
Beta Was this translation helpful? Give feedback.
-
I opened a PR to quickly solve this 😊 |
Beta Was this translation helpful? Give feedback.
-
Well now. You've hit on an interesting point. Here's how I'd ideally like the API to be... client = httpx.Client(timeout=httpx.Timeout(complete=60.0)) I'd also ideally like to drop constants from inside the codebase such as It's interesting that we're getting "global xyz" requests. I'm curious why the pattern of "single client instance" isn't used instead. Perhaps we're not being clear enough about this in the docs? Perhaps the "quickstart" API is leading our users away from client configuration and reuse? |
Beta Was this translation helpful? Give feedback.
-
Current Workaround:
Currently, the only way to set a global timeout in
httpx
across all clients and requests is by directly modifying the internal _config object. In my case, I added the following code to the main__init__.py
file:While this workaround achieves the goal of setting a default timeout, it raises several concerns about whether this is good practice, as it modifies internal variables, which is not ideal for production use (it might break the code).
Proposal for Improvement:
Looking forward to hearing everyone’s thoughts! 😊
Beta Was this translation helpful? Give feedback.
All reactions