Skip to content

Commit 8c36b51

Browse files
authored
Restore the force_close method to the ResponseHandler (#9997)
1 parent 7bbbd12 commit 8c36b51

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CHANGES/9997.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Restored the ``force_close`` method to the ``ResponseHandler`` -- by :user:`bdraco`.

aiohttp/client_proto.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def should_close(self) -> bool:
6464
or self._tail
6565
)
6666

67+
def force_close(self) -> None:
68+
self._should_close = True
69+
6770
def close(self) -> None:
6871
transport = self.transport
6972
if transport is not None:

tests/test_client_proto.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
from aiohttp.http_parser import RawResponseMessage
1313

1414

15+
async def test_force_close(loop: asyncio.AbstractEventLoop) -> None:
16+
"""Ensure that the force_close method sets the should_close attribute to True.
17+
18+
This is used externally in aiodocker
19+
https://github.com/aio-libs/aiodocker/issues/920
20+
"""
21+
proto = ResponseHandler(loop=loop)
22+
proto.force_close()
23+
assert proto.should_close
24+
25+
1526
async def test_oserror(loop: asyncio.AbstractEventLoop) -> None:
1627
proto = ResponseHandler(loop=loop)
1728
transport = mock.Mock()

0 commit comments

Comments
 (0)