Skip to content

Commit bb21c7c

Browse files
committed
Catch exception if close() in exception manager, throw another exception.
1 parent 9820975 commit bb21c7c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

httpcore/_async/connection_pool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ async def __aiter__(self) -> typing.AsyncIterator[bytes]:
403403
async for part in self._stream:
404404
yield part
405405
except BaseException as exc:
406-
await self.aclose()
406+
try:
407+
await self.aclose()
408+
except BaseException:
409+
pass
407410
raise exc from None
408411

409412
async def aclose(self) -> None:

httpcore/_sync/connection_pool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ def __iter__(self) -> typing.Iterator[bytes]:
403403
for part in self._stream:
404404
yield part
405405
except BaseException as exc:
406-
self.close()
406+
try:
407+
self.close()
408+
except BaseException:
409+
pass
407410
raise exc from None
408411

409412
def close(self) -> None:

0 commit comments

Comments
 (0)