Skip to content
Closed
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
6 changes: 4 additions & 2 deletions src/aleph/sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,11 @@ class AlephClient:
api_server: str
http_session: aiohttp.ClientSession

def __init__(self, api_server: str):
def __init__(
self, api_server: str, timeout: Optional[aiohttp.ClientTimeout] = None
):
self.api_server = api_server
self.http_session = aiohttp.ClientSession(base_url=api_server)
self.http_session = aiohttp.ClientSession(base_url=api_server, timeout=timeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't pass None as a default, there's a sentinel object in the code of aiohttp. It's gonna have to be something like this:

Suggested change
self.http_session = aiohttp.ClientSession(base_url=api_server, timeout=timeout)
params = {"base_url": api_server}
if timeout:
params["timeout"] = timeout
self.http_server = aiohttp.ClientSession(**params)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about timeout = timeout or aiohttp.client.sentinel ?


def __enter__(self) -> UserSessionSync:
return UserSessionSync(async_session=self)
Expand Down