feat: update timeout
This commit is contained in:
@@ -18,7 +18,7 @@ class BeorgService(IBeorgService):
|
|||||||
machine_uid: str,
|
machine_uid: str,
|
||||||
token: str,
|
token: str,
|
||||||
process_info: list[dict[str,Any]],
|
process_info: list[dict[str,Any]],
|
||||||
timeout: int = 15,
|
timeout: int = 120,
|
||||||
) -> None:
|
) -> None:
|
||||||
self._project_id = project_id
|
self._project_id = project_id
|
||||||
self._machine_uid = machine_uid
|
self._machine_uid = machine_uid
|
||||||
@@ -38,13 +38,18 @@ class BeorgService(IBeorgService):
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeout = aiohttp.ClientTimeout(total=self._timeout)
|
timeout = aiohttp.ClientTimeout(total=self._timeout)
|
||||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
try:
|
||||||
async with session.post(
|
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||||
f'{self.BASE_URL}{self.CREATE_ENDPOINT}',
|
async with session.post(
|
||||||
json=payload,
|
f'{self.BASE_URL}{self.CREATE_ENDPOINT}',
|
||||||
headers={'Content-Type': 'application/json'},
|
json=payload,
|
||||||
) as response:
|
headers={'Content-Type': 'application/json'},
|
||||||
data = await response.json(content_type=None)
|
) 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:
|
if response.status >= 500:
|
||||||
raise BeorgUnavailableException()
|
raise BeorgUnavailableException()
|
||||||
@@ -59,16 +64,21 @@ class BeorgService(IBeorgService):
|
|||||||
async def get_result(self,user_token: str) -> BeorgKycResultResponse:
|
async def get_result(self,user_token: str) -> BeorgKycResultResponse:
|
||||||
self._ensure_configured()
|
self._ensure_configured()
|
||||||
timeout = aiohttp.ClientTimeout(total=self._timeout)
|
timeout = aiohttp.ClientTimeout(total=self._timeout)
|
||||||
async with aiohttp.ClientSession(timeout=timeout) as session:
|
try:
|
||||||
async with session.get(
|
async with aiohttp.ClientSession(timeout=timeout) as session:
|
||||||
f'{self.BASE_URL}{self.GET_RESULT_ENDPOINT}',
|
async with session.get(
|
||||||
params={
|
f'{self.BASE_URL}{self.GET_RESULT_ENDPOINT}',
|
||||||
'token': self._token,
|
params={
|
||||||
'user_token': user_token,
|
'token': self._token,
|
||||||
},
|
'user_token': user_token,
|
||||||
headers={'Content-Type': 'application/json'},
|
},
|
||||||
) as response:
|
headers={'Content-Type': 'application/json'},
|
||||||
data = await response.json(content_type=None)
|
) 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:
|
if response.status >= 500:
|
||||||
raise BeorgUnavailableException()
|
raise BeorgUnavailableException()
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class Settings(BaseSettings):
|
|||||||
KYC_POLL_SECONDS: int = 10
|
KYC_POLL_SECONDS: int = 10
|
||||||
KYC_POLL_BATCH_SIZE: int = 20
|
KYC_POLL_BATCH_SIZE: int = 20
|
||||||
EXCLUDED_PATHS: tuple[str,...] = ('/docs','/redoc','/openapi.json','/ping')
|
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: [
|
BEORG_PROCESS_INFO: list[dict[str,Any]] = Field(default_factory=lambda: [
|
||||||
{
|
{
|
||||||
'key': 'SELFIE1',
|
'key': 'SELFIE1',
|
||||||
|
|||||||
Reference in New Issue
Block a user