Skip to content

Commit

Permalink
Restore the force_close method to the ResponseHandler (#9997)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Nov 19, 2024
1 parent 7bbbd12 commit 8c36b51
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES/9997.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Restored the ``force_close`` method to the ``ResponseHandler`` -- by :user:`bdraco`.
3 changes: 3 additions & 0 deletions aiohttp/client_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ def should_close(self) -> bool:
or self._tail
)

def force_close(self) -> None:
self._should_close = True

def close(self) -> None:
transport = self.transport
if transport is not None:
Expand Down
11 changes: 11 additions & 0 deletions tests/test_client_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@
from aiohttp.http_parser import RawResponseMessage


async def test_force_close(loop: asyncio.AbstractEventLoop) -> None:
"""Ensure that the force_close method sets the should_close attribute to True.
This is used externally in aiodocker
https://github.com/aio-libs/aiodocker/issues/920
"""
proto = ResponseHandler(loop=loop)
proto.force_close()
assert proto.should_close


async def test_oserror(loop: asyncio.AbstractEventLoop) -> None:
proto = ResponseHandler(loop=loop)
transport = mock.Mock()
Expand Down

0 comments on commit 8c36b51

Please sign in to comment.