Skip to content

Commit

Permalink
Close aiohttp response properly in Stream (#605)
Browse files Browse the repository at this point in the history
* Close aiohttp response properly

* Add changelog

* Fix for windows
  • Loading branch information
romasku committed Jul 21, 2021
1 parent 8b3c578 commit 50421c4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES/604.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue with unclosed response object in attach/exec.
8 changes: 4 additions & 4 deletions aiodocker/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ async def write_in(self, data: bytes) -> None:
await protocol._drain_helper()

async def close(self) -> None:
if self._resp is not None:
if self._resp is None:
return
if self._closed:
return
assert self._resp is not None
self._closed = True
transport = self._resp.connection.transport
transport.write_eof()
await self._resp.close()
if transport.can_write_eof():
transport.write_eof()
self._resp.close()

async def __aenter__(self) -> "Stream":
await self._init()
Expand Down

0 comments on commit 50421c4

Please sign in to comment.