Skip to content

Commit 0de453d

Browse files
olethanhPsycojoker
andauthored
Fix 146: Autenticated client was overriding the manager and it was causing issue (#149)
* Fix 146: Autenticated client was overriding the manager and it was causing issue * fix(client.http): add missing f to format string * Typing issue with hardcoded class --------- Co-authored-by: Laurent Peuch <[email protected]>
1 parent d2f56b0 commit 0de453d

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/aleph/sdk/client/authenticated_http.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,6 @@ def __init__(
8989
)
9090
self.account = account
9191

92-
async def __aenter__(self) -> "AuthenticatedAlephHttpClient":
93-
return self
94-
9592
async def ipfs_push(self, content: Mapping) -> str:
9693
"""
9794
Push arbitrary content as JSON to the IPFS service.

src/aleph/sdk/client/http.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ def http_session(self) -> aiohttp.ClientSession:
6868
raise Exception(
6969
f"{self.__class__.__name__} can only be using within an async context manager.\n\n"
7070
"Please use it this way:\n\n"
71-
" async with {self.__class__.__name__}(...) as client:"
71+
f" async with {self.__class__.__name__}(...) as client:"
7272
)
7373

7474
return self._http_session
7575

76-
async def __aenter__(self) -> "AlephHttpClient":
76+
async def __aenter__(self):
7777
if self._http_session is None:
7878
self._http_session = (
7979
aiohttp.ClientSession(
@@ -95,7 +95,9 @@ async def __aenter__(self) -> "AlephHttpClient":
9595
return self
9696

9797
async def __aexit__(self, exc_type, exc_val, exc_tb):
98-
await self.http_session.close()
98+
# Avoid cascade in error handling
99+
if self._http_session is not None:
100+
await self._http_session.close()
99101

100102
async def fetch_aggregate(self, address: str, key: str) -> Dict[str, Dict]:
101103
params: Dict[str, Any] = {"keys": key}

0 commit comments

Comments
 (0)