Skip to content

Commit

Permalink
Fix inner transport not closed (#147)
Browse files Browse the repository at this point in the history
* Fix transport not closed

* Fix connection pool not closed

* chanelog
  • Loading branch information
yanyongyu authored Dec 29, 2023
1 parent cab9520 commit 6e58129
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Fix inner transport and connection pool instances closing. (#147)
- Improved error message when the storage type is incorrect. (#138)

## 0.0.20 (12/12/2023)
Expand Down
3 changes: 3 additions & 0 deletions hishel/_async/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ async def handle_async_request(self, request: Request) -> Response:
async def aclose(self) -> None:
await self._storage.aclose()

if hasattr(self._pool, "aclose"): # pragma: no cover
await self._pool.aclose()

async def __aenter__(self: T) -> T:
return self

Expand Down
1 change: 1 addition & 0 deletions hishel/_async/_transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ async def handle_async_request(self, request: Request) -> Response:

async def aclose(self) -> None:
await self._storage.aclose()
await self._transport.aclose()

async def __aenter__(self) -> "Self":
return self
Expand Down
3 changes: 3 additions & 0 deletions hishel/_sync/_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def handle_request(self, request: Request) -> Response:
def close(self) -> None:
self._storage.close()

if hasattr(self._pool, "close"): # pragma: no cover
self._pool.close()

def __enter__(self: T) -> T:
return self

Expand Down
1 change: 1 addition & 0 deletions hishel/_sync/_transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def handle_request(self, request: Request) -> Response:

def close(self) -> None:
self._storage.close()
self._transport.close()

def __enter__(self) -> "Self":
return self
Expand Down

0 comments on commit 6e58129

Please sign in to comment.