Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

httpx.Response.elapsed cannot be accessed anymore

See original GitHub issue

I have logging that reads request time from .elapsed attribute of httpx.Request. Everything works with 0.13, but after upgrading to 0.15 I’m getting exceptions:

'.elapsed' may only be accessed after the response has been read or closed.

My versions: httpx==0.21.1 pytest-httpx==0.15.0

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

mvbrncommented, Dec 23, 2021

Unfortunately, it was fixed only for add_response and still does not work for add_callback. I’ve proposed a fix ->

Colin-bcommented, Dec 23, 2021

Thanks @mvbrn ,

Release 0.17.2 was performed today with your fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage - HTTPX
When accessing response.text , we need to decode the response bytes into a ... setting up HTTP proxies via the proxies parameter to...
Read more >
Developer Interface - HTTPX
A next-generation HTTP client for Python.
Read more >
QuickStart - HTTPX
In some cases the response may not contain an explicit encoding, ... The response content can also be accessed as bytes, for non-text...
Read more >
Requests Compatibility - HTTPX
In HTTPX, event hooks may access properties of requests and responses, but event hook callbacks cannot mutate the original request/response. If you are...
Read more >
Exceptions - HTTPX
try: response = httpx.get("") response.raise_for_status() except httpx.HTTPError as exc: print(f"HTTP Exception for {exc.request.url} ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found