Replies: 1 comment
-
|
It will be fantastic to have something to configure global defaults. This is my proposal using envars. import os
DEFAULT_TIMEOUT_CONFIG = Timeout(timeout=float(os.getenv("HTTPX_DEFAULT_TIMEOUT", 5.0)))
DEFAULT_LIMITS = Limits(
max_connections= int(os.getenv("HTTPX_DEFAULT_LIMITS_MAX_CONNECTIONS", 100)),
max_keepalive_connections=int(os.getenv("HTTPX_DEFAULT_LIMITS_MAX_KEEPALIVE_CONNECTIONS", 20))
)
DEFAULT_MAX_REDIRECTS = int(os.getenv("HTTPX_DEFAULT_MAX_REDIRECTS", 20)) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am using HTTPX inside of a wrapper class and I want to expose some of the configuration options HTTPX has (timeouts). The issue is that I would like to retain the defaults that HTTPX uses.
Python does not make it easy to use a functions defaults when calling it unless you know at compile-time which parameters will be passes. The only option is dynamically building a dictionary and unpacking it - not a nice solution.
Therefore I think that HTTPX should expose the following constants used as defaults:
httpx/httpx/_config.py
Lines 361 to 363 in 6f31bc4
I have two options currently: either copy in the code above, or import directly from the file. Neither of which is perfectly satisfying.
Beta Was this translation helpful? Give feedback.
All reactions