Repository navigation
Replies: 1 comment
|
It's already available, just not on the exception object itself. Every httpx exception raised for a request carries that request as try:
client.get(url)
except httpx.TimeoutException as exc:
timeouts = exc.request.extensions["timeout"] # {'connect': ..., 'read': ..., 'write': ..., 'pool': ...}
kind = {
httpx.ConnectTimeout: "connect",
httpx.ReadTimeout: "read",
httpx.WriteTimeout: "write",
httpx.PoolTimeout: "pool",
}[type(exc)]
raise MyError(
f"{kind.capitalize()} timed out after {timeouts[kind]}s for {exc.request.method} {exc.request.url}"
) from excTested with httpx 0.28.1 against a local server that accepts but never responds: With a per-request |
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 just ran into a situation where it would have been nice to know what the timeout time was for a ReadTimeout. My use case was to create a nice error message with how long the configured timeout was.
All reactions