raito.utils.helpers.retry_method moduleΒΆ
- async raito.utils.helpers.retry_method.retry_method(func, *args, **kwargs)[source]ΒΆ
Call an async function and retry it on Telegram errors.
Pass the coroutine function together with its arguments.
Example:
await rt.retry(bot.send_message, chat_id, "text") await rt.retry(message.answer, "text")
Retries on
TelegramRetryAfter(honouring the server-providedretry_after) and on network/server errors (TelegramNetworkError,TelegramServerError) using exponential delay. Any other exception is raised immediately.- Parameters:
- Returns:
Result of the func.
- Raises:
Exception β If all attempts fail or a non-RetryAfter exception is raised.
- Return type:
T
Deprecated since version 1.6.0: Passing an already-created coroutine (
rt.retry(bot.send_message(...))) is deprecated and will stop working in 1.8.0. It is awaited only once and cannot be retried. Pass the function and its arguments instead:rt.retry(bot.send_message, chat_id, text).