From d57caad0247c6a5d60333c8732f55ca5497c7764 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 5 Sep 2022 16:44:39 +0300 Subject: [PATCH] Retry get context --- src/fedi_api.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fedi_api.py b/src/fedi_api.py index b61edab..c43ba93 100644 --- a/src/fedi_api.py +++ b/src/fedi_api.py @@ -30,8 +30,19 @@ def mark_as_read_notification(id_notification): def get_status_context(status_id): r = requests.get(instance_point + f"/statuses/{status_id}/context", headers=headers) - return r.json() + if r.status_code == 200: + return r.json() + else: + http_code = r.status_code + logger.error(f'Ошибка получения контекста треда {status_id}: {http_code}') + while r.status_code != 200: + time.sleep(30) + logger.info('Повторный запрос треда...') + r = requests.get(instance_point + f"/statuses/{status_id}/context", headers=headers) + return r.json() + + def get_status(status_id): r = requests.get(instance_point + f"/statuses/{status_id}", headers=headers)