feat: update timeout

This commit is contained in:
2026-05-12 21:48:35 +03:00
parent b89534cacd
commit 342e1e38c4
2 changed files with 29 additions and 19 deletions

View File

@@ -18,7 +18,7 @@ class BeorgService(IBeorgService):
machine_uid: str,
token: str,
process_info: list[dict[str,Any]],
timeout: int = 15,
timeout: int = 120,
) -> None:
self._project_id = project_id
self._machine_uid = machine_uid
@@ -38,13 +38,18 @@ class BeorgService(IBeorgService):
}
timeout = aiohttp.ClientTimeout(total=self._timeout)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post(
f'{self.BASE_URL}{self.CREATE_ENDPOINT}',
json=payload,
headers={'Content-Type': 'application/json'},
) as response:
data = await response.json(content_type=None)
try:
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.post(
f'{self.BASE_URL}{self.CREATE_ENDPOINT}',
json=payload,
headers={'Content-Type': 'application/json'},
) as response:
data = await response.json(content_type=None)
except TimeoutError:
raise BeorgUnavailableException() from None
except aiohttp.ClientError:
raise BeorgUnavailableException() from None
if response.status >= 500:
raise BeorgUnavailableException()
@@ -59,16 +64,21 @@ class BeorgService(IBeorgService):
async def get_result(self,user_token: str) -> BeorgKycResultResponse:
self._ensure_configured()
timeout = aiohttp.ClientTimeout(total=self._timeout)
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.get(
f'{self.BASE_URL}{self.GET_RESULT_ENDPOINT}',
params={
'token': self._token,
'user_token': user_token,
},
headers={'Content-Type': 'application/json'},
) as response:
data = await response.json(content_type=None)
try:
async with aiohttp.ClientSession(timeout=timeout) as session:
async with session.get(
f'{self.BASE_URL}{self.GET_RESULT_ENDPOINT}',
params={
'token': self._token,
'user_token': user_token,
},
headers={'Content-Type': 'application/json'},
) as response:
data = await response.json(content_type=None)
except TimeoutError:
raise BeorgUnavailableException() from None
except aiohttp.ClientError:
raise BeorgUnavailableException() from None
if response.status >= 500:
raise BeorgUnavailableException()

View File

@@ -39,7 +39,7 @@ class Settings(BaseSettings):
KYC_POLL_SECONDS: int = 10
KYC_POLL_BATCH_SIZE: int = 20
EXCLUDED_PATHS: tuple[str,...] = ('/docs','/redoc','/openapi.json','/ping')
BEORG_TIMEOUT: int = 15
BEORG_TIMEOUT: int = 120
BEORG_PROCESS_INFO: list[dict[str,Any]] = Field(default_factory=lambda: [
{
'key': 'SELFIE1',