Browse Source

Обработка ошибки подключения к серверу

Жирный грязный try excert
master
Дмитрий 3 years ago
parent
commit
42a9998b14
  1. 3
      solution.py

3
solution.py

@ -100,6 +100,7 @@ async def send_async_request(cfg: Config, json_body: dict) -> None:
url = cfg.central_host_url
portion = cfg.request_portion
try:
async with aiohttp.ClientSession(connector=conn) as session:
# получаем количесвто записей
count = await get_records_count(session, url)
@ -114,6 +115,8 @@ async def send_async_request(cfg: Config, json_body: dict) -> None:
resp = await response.json()
hosts = [i["hostname"] for i in resp.get("result")]
await write_config_files(hosts, cfg, template)
except ClientConnectorError:
print(f"Невозможно подключиться к серверу {url}")
def read_config(path_to_conf_file: str, section: str = "Main") -> Config:

Loading…
Cancel
Save