encode / httpx

A next generation HTTP client for Python. 🦋

Home Page:https://www.python-httpx.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: 'AsyncLock' object has no attribute '_anyio_lock'

T-256 opened this issue · comments

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\Tester\.rye\py\cpython@3.12.0\install\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Tester\.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\Tester\.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 #2885 (comment)

That is httpcore issue.