Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/aleph/sdk/client/authenticated_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 5 additions & 3 deletions src/aleph/sdk/client/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ 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

async def __aenter__(self) -> "AlephHttpClient":
async def __aenter__(self):
if self._http_session is None:
self._http_session = (
aiohttp.ClientSession(
Expand All @@ -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}
Expand Down