aio-libs / aiodocker

Python Docker API client based on asyncio and aiohttp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Stream doesn't closes response object

romasku opened this issue · comments

Long story short

When I use container.attach() it opens a connection as expected, but the underlying aiohttp response object is not closed. It leads to a warnings:

ResourceWarning: Unclosed response <ClientResponse(http://10.1.0.19:2375/v1.39/containers/912a83018d776abf6bc7e6ad0a7abca727a1dc8df40e286681abe779b8b3a473/attach?detachKeys=&logs=1&stdin=0&stdout=1&stderr=1&stream=1) [101 UPGRADED]>
  • Expected behaviour: no warning, response object closed
  • Actual behaviour: warning thrown about unclosed response object.

Additional details:

In the following code

async def close(self) -> None:
if self._resp is not None:
return
if self._closed:
return
assert self._resp is not None

Line if self._resp is not None: looks very suspicious, I think that the not there is a bug.