From e4ca84c2ea09ad9e3260e15f1b12464704dcf362 Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Wed, 14 Aug 2024 17:08:22 +0200 Subject: [PATCH 1/3] Fix 146: Autenticated client was overriding the manager and it was causing issue --- src/aleph/sdk/client/authenticated_http.py | 3 --- src/aleph/sdk/client/http.py | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/aleph/sdk/client/authenticated_http.py b/src/aleph/sdk/client/authenticated_http.py index cb2f3e01..f84b97ca 100644 --- a/src/aleph/sdk/client/authenticated_http.py +++ b/src/aleph/sdk/client/authenticated_http.py @@ -89,9 +89,6 @@ def __init__( ) self.account = account - async def __aenter__(self) -> "AuthenticatedAlephHttpClient": - return self - async def ipfs_push(self, content: Mapping) -> str: """ Push arbitrary content as JSON to the IPFS service. diff --git a/src/aleph/sdk/client/http.py b/src/aleph/sdk/client/http.py index 8f3b7f90..5afdae65 100644 --- a/src/aleph/sdk/client/http.py +++ b/src/aleph/sdk/client/http.py @@ -95,7 +95,9 @@ async def __aenter__(self) -> "AlephHttpClient": return self async def __aexit__(self, exc_type, exc_val, exc_tb): - await self.http_session.close() + # Avoid cascade in error handling + if self._http_session is not None: + await self._http_session.close() async def fetch_aggregate(self, address: str, key: str) -> Dict[str, Dict]: params: Dict[str, Any] = {"keys": key} From 41b61bcded2a1ab2ee6f4280bd770b3a1e5e88cf Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 14 Aug 2024 17:12:14 +0200 Subject: [PATCH 2/3] fix(client.http): add missing f to format string --- src/aleph/sdk/client/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aleph/sdk/client/http.py b/src/aleph/sdk/client/http.py index 5afdae65..cabedb86 100644 --- a/src/aleph/sdk/client/http.py +++ b/src/aleph/sdk/client/http.py @@ -68,7 +68,7 @@ def http_session(self) -> aiohttp.ClientSession: raise Exception( f"{self.__class__.__name__} can only be using within an async context manager.\n\n" "Please use it this way:\n\n" - " async with {self.__class__.__name__}(...) as client:" + f" async with {self.__class__.__name__}(...) as client:" ) return self._http_session From ee6e2640401517d1f36423171015e9d97e23a81f Mon Sep 17 00:00:00 2001 From: Olivier Le Thanh Duong Date: Wed, 14 Aug 2024 17:19:31 +0200 Subject: [PATCH 3/3] Typing issue with hardcoded class --- src/aleph/sdk/client/http.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aleph/sdk/client/http.py b/src/aleph/sdk/client/http.py index cabedb86..9dfb588a 100644 --- a/src/aleph/sdk/client/http.py +++ b/src/aleph/sdk/client/http.py @@ -73,7 +73,7 @@ def http_session(self) -> aiohttp.ClientSession: return self._http_session - async def __aenter__(self) -> "AlephHttpClient": + async def __aenter__(self): if self._http_session is None: self._http_session = ( aiohttp.ClientSession(