Repository navigation
Replies: 2 comments
|
A caller-side conversion can keep the units explicit without depending on a new constructor overload. Convert timedelta to total_seconds(), rather than .seconds (which drops whole days and microseconds): from datetime import timedelta
import math
import httpx
def seconds(value: timedelta) -> float:
result = value.total_seconds()
if not math.isfinite(result) or result < 0:
raise ValueError("timeout must be finite and non-negative")
return result
timeout = httpx.Timeout(
seconds(timedelta(seconds=30)),
connect=seconds(timedelta(seconds=5)),
)Pass that timeout to Client/AsyncClient or a request method. This is a conversion workaround, not a statement about whether your proposed API should be accepted. HTTPX 0.28.1 interprets these as connect/read/write/pool timeouts, not one total wall-clock deadline. Use None explicitly when you intend to disable a phase. Checked fractional seconds, a duration over one day, negative rejection, and propagation into all four Timeout fields. Timeout configuration. Validation: HTTPX 0.28.1, Python 3.11.9. |
0 replies
|
Yes - this is what I do now. |
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 would love for the timeout to receive timedelta's and thereby be explicit in the code what the timeout length is. I've added a pull request with the basic created, but I would expand it to also work on the different method like get etc.
All reactions