aio-libs / aiodocker

Python Docker API client based on asyncio and aiohttp
Other
441 stars 101 forks source link

aiohttp 3.10 appears not to work with aiodocker #889

Open Julian opened 3 months ago

Julian commented 3 months ago

Long story short

aiohttp==3.10.0 (released mid-July) appears to break aiodocker entirely here.

Any use of the library produces an exception complaining about the use of unix://localhost, which I see aiodocker uses as a dummy URI.

Traceback (most recent call last):
  File "<string>", line 10, in <module>
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "<string>", line 8, in main
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 190, in version
    data = await self._query_json("version")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 319, in _query_json
    async with self._query(
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 231, in _query
    yield await self._do_query(
          ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 257, in _do_query
    await self._check_version()
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 209, in _check_version
    ver = await self._query_json("version", versioned_api=False)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 319, in _query_json
    async with self._query(
  File "/opt/homebrew/Cellar/python@3.12/3.12.4/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 231, in _query
    yield await self._do_query(
          ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiodocker/docker.py", line 267, in _do_query
    response = await self.session.request(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/julian/Desktop/venv/lib/python3.12/site-packages/aiohttp/client.py", line 510, in _request
    raise NonHttpUrlClientError(url)
aiohttp.client_exceptions.NonHttpUrlClientError: unix://localhost/version

How to reproduce

Run e.g.:

rm -rf venv && uv venv venv && uv pip install --python venv/bin/python aiodocker 'aiohttp>=3.10' && venv/bin/python -c '                                                                                                                                                   julian@Airm ●
import asyncio

from aiodocker import Docker

async def main():
    async with Docker() as docker:
        print(await docker.version())

asyncio.run(main())

Your environment

macOS with a remote docker host set to:

⊙  echo $DOCKER_HOST                                                                                                                                                                                                                                                          julian@Airm ●
unix:///Users/julian/Library/Application Support/containers/podman/machine/qemu/podman.sock

c.f. #833, though that seems no longer accurate (I was using 3.9 here myself for awhile so I think 3.9 seemed fine?) -- more relevant seems to be https://github.com/aio-libs/aiodocker/pull/885 where it seems aiohttp 3.10 breaks aiodocker's own suite.

I haven't looked into what the fix looks like (one would hope it's tiny?) but perhaps if it isn't completely trivial, simply pinning away from 3.10 is a temporary solution.