Uh oh!
There was an error while loading. Please reload this page.
httpx.Timeout must include a default - #1085
Conversation
lovelydinosaur
commented
Jul 24, 2020
Related to this... we could feasible want to prefer naming like |
jcugat
commented
Jul 25, 2020
The only thing that makes me go a bit 🤔 is that there's no way to modify a single timeout (the connect one for example) without either removing the other timeouts (with Why not allow something like this: httpx.Timeout(read_timeout=10.0) # Everything else keeps the default |
lovelydinosaur
commented
Jul 25, 2020
Right, which is actually part of the point here. The default timeout for Forcing the default value to be explicit makes this all more clear. The user needs to explicit use either |
jcugat
commented
Jul 25, 2020
My worry is that the discoverability of the current default timeout is not obvious. It's only set in Would you be open to having something like: classTimeout:
DEFAULT: Final=5.0So then the use-case I proposed could be achieved with: httpx.Timeout(httpx.Timeout.DEFAULT, read_timeout=10.0) |
I agree that the current state of not enforcing a default to lead to a "gotcha" situation - where people might not expect the no-explicit-default usage to actually mean "no timeouts by default". So +1 from me on this. Not certain if we should expose the default of 5s in code, but it looks likes this can be added incrementally from this PR. Also +1 on reducing the verbosity caused by the |
For consideration, wrt. 1.0 API tightening.
Ensures that
httpx.Timeout(...)must strictly include an explicit default.Usages like
httpx.Timeout()andhttpx.Timeout(read_timeout=5.0)are no longer valid. The default value must be explicitly included. Eg.httpx.Timeout(None)andhttpx.Timeout(None, read_timeout=5.0).Docstring on the class is:
Timeout configuration.
Usage:
httpx.Timeout(None)No timeouts.httpx.Timeout(5.0)5s timeout on all operations.httpx.Timeout(None, connect_timeout=5.0)5s timeout on connect, no other timeouts.httpx.Timeout(5.0, connect_timeout=10.0)10s timeout on connect. 5s timeout elsewhere.httpx.Timeout(5.0, pool_timeout=None)No timeout on acquiring connection from pool. 5s timeout elsewhere.