Добавил исключение ClientConnectorError

This commit is contained in:
Григорич 2023-06-06 11:28:44 +03:00
parent b7272a6e1e
commit b5c046ea25

View File

@ -21,8 +21,8 @@ class EtlLoader:
self.etl = EtlConfig() self.etl = EtlConfig()
self.api_config = ApiConfig() self.api_config = ApiConfig()
@backoff.on_exception(backoff.expo, (asyncio.TimeoutError, ), base=2, factor=1, @backoff.on_exception(backoff.expo, (asyncio.TimeoutError, aiohttp.ClientConnectorError), base=2, factor=1,
max_value=etl_config.max_wait_size, max_tries=None) max_value=int(etl_config.max_wait_size), max_tries=None)
async def load_data(self, state: State, abitr: Abitr, iblock_id: int, storage: BaseStorage): async def load_data(self, state: State, abitr: Abitr, iblock_id: int, storage: BaseStorage):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
logging.info(f"Информация об абитуриенте: {abitr.FIO}") logging.info(f"Информация об абитуриенте: {abitr.FIO}")
@ -33,7 +33,7 @@ class EtlLoader:
async with session.post( async with session.post(
url=f"{self.etl.protocol}://{self.etl.host}:{self.etl.port}", url=f"{self.etl.protocol}://{self.etl.host}:{self.etl.port}",
data=data_dict, data=data_dict,
timeout=aiohttp.ClientTimeout(total=30) timeout=aiohttp.ClientTimeout(total=int(etl_config.max_wait_size))
) as response: ) as response:
pass pass
state.set_state(f'iblock_{iblock_id}', abitr.ID) state.set_state(f'iblock_{iblock_id}', abitr.ID)