Skip to content

Commit

Permalink
fix: ensure 'AppInstallationAuth' closes its internal client
Browse files Browse the repository at this point in the history
  • Loading branch information
ahal committed Oct 27, 2023
1 parent c2c2838 commit 7524766
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/simple_github/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ async def get_token(self) -> str:
"""Returns"""
...

async def close(self) -> None:
"""Close the authentication if necessary."""
pass


class TokenAuth(Auth):
def __init__(self, token):
Expand Down Expand Up @@ -115,6 +119,10 @@ def __init__(
self._client = Client(auth=self.app)
self._generator = self._gen_installation_token()

async def close(self) -> None:
"""Close the Client used to fetch the installation token."""
await self._client.close()

async def _get_installation_id(self) -> str:
"""Return the app's installation id for owner.
Expand Down
1 change: 1 addition & 0 deletions src/simple_github/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async def __aexit__(self, *excinfo):
await self.close()

async def close(self) -> None:
await self.auth.close()
if self._gql_client:
await self._gql_client.close_async()

Expand Down

0 comments on commit 7524766

Please sign in to comment.