question-mark
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.

High workload issue "partially initialized module 'anyio._backends._asyncio' has no attribute 'checkpoint_if_cancelled'"

See original GitHub issue

Hey,

I notice some error are thrown sporadically with no reason

 core.error_handler:log_error:18 - <class 'AttributeError'> - AttributeError("partially initialized module 'anyio._backends._asyncio' has no attribute 'checkpoint_if_cancelled' (most likely due to a circular import)") 

Full stack trace

File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1568, in send
 response = await self._send_handling_auth(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1604, in _send_handling_auth
 response = await self._send_handling_redirects(
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1640, in _send_handling_redirects
 response = await self._send_single_request(request, timeout)
File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1681, in _send_single_request
 ) = await transport.handle_async_request(
File "/usr/local/lib/python3.9/site-packages/httpx_socks/_async_transport.py", line 60, in handle_async_request
 response = await connection.handle_async_request(
File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection.py", line 128, in handle_async_request
 async with self.request_lock:
File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/base.py", line 76, in __aenter__
 await self.acquire()
File "/usr/local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 104, in acquire
 await self._lock.acquire()
File "/usr/local/lib/python3.9/site-packages/anyio/_core/_synchronization.py", line 117, in acquire
 await checkpoint_if_cancelled()
File "/usr/local/lib/python3.9/site-packages/anyio/lowlevel.py", line 42, in checkpoint_if_cancelled
 await get_asynclib().checkpoint_if_cancelled()

Env: Linux : 5.4.0-80-generic - Running in k8s Python interpreter : Python 3.9.5

Dependencies :

hpack==4.0.0
httpcore==0.13.6
httptools==0.2.0
httpx==0.18.2
httpx-socks==0.4.1
hyperframe==6.0.1
h11==0.12.0
h2==4.0.0

Did someone already experience the same issue ? My project is using asyncio package as async lib, so nothing exoctic here. The send method is called in a multi threaded app.

Thanks, will continue to dig on my side what happened

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
2-Xcommented, Oct 7, 2021

@tomchristie lol that solves my issue, thanks! i was just going by the docs which only use AsyncClient as an example and that misled me a bit

1reaction
tomchristiecommented, Oct 7, 2021

Since my application requires http/2, I need to make an async client with httpx (since that’s the only one that supports http/2)

You can use HTTP/2 with a regular client…

client = httpx.Client(http2=True)

(Doesn’t need to be async)

Read more comments on GitHub >

github_iconTop Results From Across the Web

partially initialized module 'asyncio' has no attribute 'Future ...
AttributeError: partially initialized module 'asyncio' has no attribute 'Future' (most likely due to a circular import) tornado==6.0.4 ...
Read more >
Python3.6 AttributeError: module 'asyncio' has no attribute 'run'
If anyone is having a problem with no current loop try: loop = asyncio.**new**_event_loop() result = loop.run_until_complete(coro).
Read more >
AnyIO - Release 3.6.2 Alex Grönholm
AnyIO is an asynchronous networking and concurrency library that works on top of either asyncio or trio. It implements.
Read more >
Error: module 'anyio' has no attribute 'Lock' - Forum
Raised in behalf of user as he is getting this error though using the .NET library and so far he is having no...
Read more >
High workload issue "partially initialized module 'anyio ...
High workload issue "partially initialized module 'anyio._backends._asyncio' has no attribute 'checkpoint_if_cancelled'"
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 Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found