From 7524766c4acbe3dc509f7357af25c2f3e97d47eb Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Fri, 27 Oct 2023 11:14:44 -0400 Subject: [PATCH] fix: ensure 'AppInstallationAuth' closes its internal client --- src/simple_github/auth.py | 8 ++++++++ src/simple_github/client.py | 1 + 2 files changed, 9 insertions(+) diff --git a/src/simple_github/auth.py b/src/simple_github/auth.py index b1c2030..3d56461 100644 --- a/src/simple_github/auth.py +++ b/src/simple_github/auth.py @@ -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): @@ -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. diff --git a/src/simple_github/client.py b/src/simple_github/client.py index 307833d..4aee054 100644 --- a/src/simple_github/client.py +++ b/src/simple_github/client.py @@ -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()