-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'AsyncLock' object has no attribute '_anyio_lock' #825
Comments
Here's the same thing slimmed down to just an example.py import httpcore
import asyncio
async def main():
async with httpcore.AsyncConnectionPool() as pool:
response = await pool.request("GET", "https://www.example.com")
print(response)
asyncio.run(main()) console: $ python3 -m venv venv
$ venv/bin/pip install httpcore[asyncio]
$ venv/bin/pip uninstall anyio
$ venv/bin/python example.py
Traceback (most recent call last):
File "/Users/tomchristie/Temp/./example.py", line 7, in main
response = await pool.request("GET", "https://www.example.com")
File "/Users/tomchristie/Temp/venv/lib/python3.10/site-packages/httpcore/_async/interfaces.py", line 43, in request
response = await self.handle_async_request(request)
File "/Users/tomchristie/Temp/venv/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 224, in handle_async_request
async with self._pool_lock:
File "/Users/tomchristie/Temp/venv/lib/python3.10/site-packages/httpcore/_synchronization.py", line 62, in __aenter__
self.setup()
File "/Users/tomchristie/Temp/venv/lib/python3.10/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 "/Users/tomchristie/Temp/./example.py", line 11, in <module>
asyncio.run(main())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/Users/tomchristie/Temp/./example.py", line 6, in main
async with httpcore.AsyncConnectionPool() as pool:
File "/Users/tomchristie/Temp/venv/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 327, in __aexit__
await self.aclose()
File "/Users/tomchristie/Temp/venv/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 312, in aclose
async with self._pool_lock:
File "/Users/tomchristie/Temp/venv/lib/python3.10/site-packages/httpcore/_synchronization.py", line 67, in __aenter__
await self._anyio_lock.acquire()
AttributeError: 'AsyncLock' object has no attribute '_anyio_lock' 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.py |
The same thing happened to me with the following dependencies, with httpx
Error: |
Try install httpx + httpcore 1.0 then remove anyio. Error:
Originally posted by @T-256 in encode/httpx#2885 (comment)
The text was updated successfully, but these errors were encountered: