Repository navigation
AttributeError: 'AsyncLock' object has no attribute '_anyio_lock' #825
Copy link
Copy link
Closed
Description
Try install httpx + httpcore 1.0 then remove anyio. Error:
(.venv) E:\hcore1>python app.py
Traceback (most recent call last):
File "E:\hcore1\app.py", line 6, in main
r = await client.get('https://www.example.com/')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 1757, in get
return await self.request(
^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 1530, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 1617, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 1645, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 1682, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 1719, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpx\_transports\default.py", line 366, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\hcore1\.venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 224, in handle_async_request
async with self._pool_lock:
File "E:\hcore1\.venv\Lib\site-packages\httpcore\_synchronization.py", line 62, in __aenter__
self.setup()
File "E:\hcore1\.venv\Lib\site-packages\httpcore\_synchronization.py", line 55, in setup
raise RuntimeError(
RuntimeError: Running with asyncio requires installation of 'httpcore[asyncio]'.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\hcore1\app.py", line 8, in <module>
asyncio.run(main())
File "C:\Users\User\.rye\py\cpython@3.12.0\install\Lib\asyncio\runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\User\.rye\py\cpython@3.12.0\install\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\User\.rye\py\cpython@3.12.0\install\Lib\asyncio\base_events.py", line 664, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "E:\hcore1\app.py", line 5, in main
async with httpx.AsyncClient() as client:
File "E:\hcore1\.venv\Lib\site-packages\httpx\_client.py", line 2003, in __aexit__
await self._transport.__aexit__(exc_type, exc_value, traceback)
File "E:\hcore1\.venv\Lib\site-packages\httpx\_transports\default.py", line 345, in __aexit__
await self._pool.__aexit__(exc_type, exc_value, traceback)
File "E:\hcore1\.venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 327, in __aexit__
await self.aclose()
File "E:\hcore1\.venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 312, in aclose
async with self._pool_lock:
File "E:\hcore1\.venv\Lib\site-packages\httpcore\_synchronization.py", line 67, in __aenter__
await self._anyio_lock.acquire()
^^^^^^^^^^^^^^^^
AttributeError: 'AsyncLock' object has no attribute '_anyio_lock'
(.venv) E:\hcore1>
Originally posted by @T-256 in encode/httpx#2885 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
lovelydinosaur commentedon Oct 13, 2023
Here's the same thing slimmed down to just an
httpcoreexample...example.py
console:
This is okay... can see an appropriate RuntimeError when we deliberately break the installation, but it could be neater.
edit:
A better replication of this...
$ python3 -m venv venv $ venv/bin/pip install httpcore # Intention was to install `httpcore[asyncio]` $ venv/bin/python example.pychamikabm commentedon Oct 30, 2023
The same thing happened to me with the following dependencies, with httpx
httpx==0.25.0 sniffio==1.3.0 certifi==2023.7.22 idna==3.4 httpcore==0.18.0 anyio>=3.0,<5.0Error:
graphql-async-test-service | File "/app/graphql_service/manager_libraries/base.py", line 119, in async_http_request graphql-async-test-service | resp = await httpx_client(*args, **kwargs) graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1848, in post graphql-async-test-service | return await self.request( graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1530, in request graphql-async-test-service | return await self.send(request, auth=auth, follow_redirects=follow_redirects) graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1617, in send graphql-async-test-service | response = await self._send_handling_auth( graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1645, in _send_handling_auth graphql-async-test-service | response = await self._send_handling_redirects( graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1682, in _send_handling_redirects graphql-async-test-service | response = await self._send_single_request(request) graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1719, in _send_single_request graphql-async-test-service | response = await transport.handle_async_request(request) graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpx/_transports/default.py", line 366, in handle_async_request graphql-async-test-service | resp = await self._pool.handle_async_request(req) graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 224, in handle_async_request graphql-async-test-service | async with self._pool_lock: graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpcore/_synchronization.py", line 48, in __aenter__ graphql-async-test-service | self.setup() graphql-async-test-service | File "/usr/local/lib/python3.9/site-packages/httpcore/_synchronization.py", line 41, in setup graphql-async-test-service | raise RuntimeError( graphql-async-test-service | RuntimeError: Running under asyncio requires the 'anyio' package to be installed.