Add option to raise last error instead of generic ValueError (#1571)

This commit is contained in:
Tulir Asokan
2020-10-01 12:53:17 +03:00
committed by Lonami Exo
parent d5e4398ace
commit 8ce7e776c1
2 changed files with 16 additions and 1 deletions

View File

@@ -160,6 +160,12 @@ class TelegramBaseClient(abc.ABC):
was for 21s, it would ``raise FloodWaitError`` instead. Values
larger than a day (like ``float('inf')``) will be changed to a day.
raise_last_call_error (`bool`, optional):
When API calls fail in a way that causes Telethon to retry
automatically, should the RPC error of the last attempt be raised
instead of a generic ValueError. This is mostly useful for
detecting when Telegram has internal issues.
device_model (`str`, optional):
"Device model" to be sent when creating the initial connection.
Defaults to 'PC (n)bit' derived from ``platform.uname().machine``, or its direct value if unknown.
@@ -216,6 +222,7 @@ class TelegramBaseClient(abc.ABC):
auto_reconnect: bool = True,
sequential_updates: bool = False,
flood_sleep_threshold: int = 60,
raise_last_call_error: bool = False,
device_model: str = None,
system_version: str = None,
app_version: str = None,
@@ -306,6 +313,8 @@ class TelegramBaseClient(abc.ABC):
)
)
self._raise_last_call_error = raise_last_call_error
self._request_retries = request_retries
self._connection_retries = connection_retries
self._retry_delay = retry_delay or 0