Repository navigation
Elapsed time with AsyncClient seems to include wait time #2882
Replies: 1 comment
|
I checked this on HTTPX 0.28.1 with an isolated AsyncClient and MockTransport experiment. I waited 250 ms after building the request, then spent 50 ms inside the mock transport and 200 ms between receiving response headers and closing the stream. Response.elapsed was unavailable until close and reported about 268 ms. It excluded the delay before send and included the time the response stream was left open. This matches the 0.28.1 client code, which starts the timer just before handling the request through the transport and sets elapsed when the stream closes. Real transport calls can also include connection-pool wait. For dispatch-to-headers latency, measure around await client.send(request, stream=True) with perf_counter() and close the response afterward. That measurement still includes pool wait and is distinct from on-the-wire network time. The reproduction and write-up were AI-assisted. |
Uh oh!
There was an error while loading. Please reload this page.
Hello there!
I'm trying (amongst other things) to get response time data of requests, in order to measure the performance of an internal tool.
On paper,
Response.elapsedgives me exactly what I need.However, when switching to
AsyncClientin order to handle higher requests volumes, it seems theelapsedvalue also includes the "wait" time between the creation of the requests and the moment it's executed.IMHO that's not the behavior we want :
elapsedshould indicate the actual "network" time.Hope I'm understandable 😂
What do you think?
All reactions