From 37503069333e25e549b1b123101e5511705e64eb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 10 Sep 2019 14:04:56 +0200 Subject: [PATCH] Don't crash in case of weird errors in safe_api_call --- royalnet/bots/telegram.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index 81b6137b..76713fd6 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -2,6 +2,7 @@ import telegram import telegram.utils.request import typing import uuid +import urllib3 import asyncio import sentry_sdk import logging as _logging @@ -135,7 +136,12 @@ class TelegramBot(GenericBot): except telegram.error.RetryAfter as error: log.warning(f"Rate limited during {f.__qualname__} (retrying in 15s): {error}") await asyncio.sleep(15) - except telegram.error.TelegramError as error: + continue + except urllib3.exceptions.HTTPError as error: + log.warning(f"urllib3 HTTPError during {f.__qualname__} (retrying in 15s): {error}") + await asyncio.sleep(15) + continue + except Exception as error: log.error(f"{error.__class__.__qualname__} during {f} (skipping): {error}") sentry_sdk.capture_exception(error) break