Unverified Commit b7178b4b authored by Jakob Görgen's avatar Jakob Görgen
Browse files

symphony/client: added timeouts to client calls

parent d4ad4314
......@@ -83,7 +83,8 @@ class TokenClient:
token = None
async with aiohttp.ClientSession() as session:
timeout = aiohttp.ClientTimeout(total=client_settings().timeout_sec)
async with aiohttp.ClientSession(timeout=timeout) as session:
# get device_code, interval, verification_uri, user_code
device_code = None
......@@ -143,7 +144,8 @@ class TokenClient:
assert old_token.is_refresh_valid()
token = None
async with aiohttp.ClientSession() as session:
timeout = aiohttp.ClientTimeout(total=client_settings().timeout_sec)
async with aiohttp.ClientSession(timeout=timeout) as session:
# get device_code, interval, verification_uri, user_code
async with session.post(
......@@ -168,7 +170,8 @@ class TokenClient:
async def resource_token(self, token: Token, ticket: str) -> Token:
assert token.is_access_valid()
async with aiohttp.ClientSession() as session:
timeout = aiohttp.ClientTimeout(total=client_settings().timeout_sec)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post(
url=self._token_url,
headers={"Authorization": f"Bearer {token.access_token}"},
......
......@@ -58,7 +58,8 @@ class BaseClient:
self, overwrite_headers: dict[str, typing.Any] | None = None
) -> typing.AsyncIterator[aiohttp.ClientSession]:
headers = await self._get_headers(overwrite_headers=overwrite_headers)
session = aiohttp.ClientSession(headers=headers)
timeout = aiohttp.ClientTimeout(total=client_settings().timeout_sec)
session = aiohttp.ClientSession(headers=headers, timeout=timeout)
try:
yield session
finally:
......
......@@ -30,6 +30,7 @@ import rich
import rich.color
import rich.style
import rich.text
import rich.console
from simbricks.orchestration import instantiation, simulation, system
......
......@@ -32,6 +32,7 @@ class ClientSettings(BaseSettings):
namespace: str = ""
runner_id: int = -1
timeout_sec: int = 20
@lru_cache
def client_settings() -> ClientSettings:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment