Cannot pass timeout to a show() or any other function, makes aiodocker hang long time
ualex73 opened this issue · comments
Long story short
- Expected behaviour: Timeout passable as argument
- Actual behaviour: Timeout does not seem to be used in "docker.py" in _do_query function
How to reproduce
Setup connection, block connection with e.g. "iptables".
Call the "show" of a container:
outp = await self._container.show(timeout=3)
It does not timeout after 3 seconds, it hangs for many minutes. Also, debugging in "_do_query", I do not see the value passed to the function from the show.
Your environment
Debian 12, standard Docker
In general, the recommended way to enforce timeout is to use asyncio.timeout()
added in Python 3.11, instead of manually specifying the timeouts to all async APIs.
Timeouts in arbitrary async codes appear as cancellation from outside from the perspective of target codes.
See: https://docs.python.org/3/library/asyncio-task.html#asyncio.Timeout
However, there are more subtle cases that you may want to control detailed connection timeout behavior like when accessing remote Docker instances via TCP, for example.
I think it would be a nice idea to expose aiohttp.ClientTimeout
interface for aiodocker users to control more details.
Currently you can customize some parts of the timeout by passing your own created aiohttp connectors.