1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Don't crash in case of weird errors in safe_api_call

This commit is contained in:
Steffo 2019-09-10 14:04:56 +02:00
parent 0a22319d17
commit 3750306933

View file

@ -2,6 +2,7 @@ import telegram
import telegram.utils.request import telegram.utils.request
import typing import typing
import uuid import uuid
import urllib3
import asyncio import asyncio
import sentry_sdk import sentry_sdk
import logging as _logging import logging as _logging
@ -135,7 +136,12 @@ class TelegramBot(GenericBot):
except telegram.error.RetryAfter as error: except telegram.error.RetryAfter as error:
log.warning(f"Rate limited during {f.__qualname__} (retrying in 15s): {error}") log.warning(f"Rate limited during {f.__qualname__} (retrying in 15s): {error}")
await asyncio.sleep(15) 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}") log.error(f"{error.__class__.__qualname__} during {f} (skipping): {error}")
sentry_sdk.capture_exception(error) sentry_sdk.capture_exception(error)
break break