This commit is contained in:
Timothy Jaeryang Baek
2026-04-14 01:17:39 -05:00
parent cced77b584
commit 37658fd541
2 changed files with 16 additions and 4 deletions
+8 -2
View File
@@ -906,10 +906,16 @@ async def cleanup_response(
):
if response:
if not response.closed:
await response.close()
# aiohttp 3.9+ made ClientResponse.close() synchronous (returns None).
# Older versions returned a coroutine. Handle both gracefully.
result = response.close()
if result is not None:
await result
if session:
if not session.closed:
await session.close()
result = session.close()
if result is not None:
await result
async def stream_wrapper(response, session, content_handler=None):
+8 -2
View File
@@ -93,10 +93,16 @@ async def cleanup_response(
"""
if response:
if not response.closed:
await response.close()
# aiohttp 3.9+ made ClientResponse.close() synchronous (returns None).
# Older versions returned a coroutine. Handle both gracefully.
result = response.close()
if result is not None:
await result
if session:
if not session.closed:
await session.close()
result = session.close()
if result is not None:
await result
async def stream_wrapper(response, session=None, content_handler=None):