mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-22 07:06:26 +01:00
Respect RetryAfter with polling Updater
This commit is contained in:
parent
de96cc87ea
commit
a68cf8d464
2 changed files with 5 additions and 2 deletions
|
@ -110,4 +110,4 @@ class RetryAfter(TelegramError):
|
|||
"""
|
||||
super(RetryAfter,
|
||||
self).__init__('Flood control exceeded. Retry in {} seconds'.format(retry_after))
|
||||
self.retry_after = retry_after
|
||||
self.retry_after = float(retry_after)
|
||||
|
|
|
@ -30,7 +30,7 @@ from queue import Queue
|
|||
|
||||
from telegram import Bot, TelegramError
|
||||
from telegram.ext import Dispatcher, JobQueue
|
||||
from telegram.error import Unauthorized, InvalidToken
|
||||
from telegram.error import Unauthorized, InvalidToken, RetryAfter
|
||||
from telegram.utils.request import Request
|
||||
from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler)
|
||||
|
||||
|
@ -233,6 +233,9 @@ class Updater(object):
|
|||
try:
|
||||
updates = self.bot.getUpdates(
|
||||
self.last_update_id, timeout=timeout, network_delay=network_delay)
|
||||
except RetryAfter as e:
|
||||
self.logger.info(str(e))
|
||||
cur_interval = 0.5 + e.retry_after
|
||||
except TelegramError as te:
|
||||
self.logger.error("Error while getting Updates: {0}".format(te))
|
||||
|
||||
|
|
Loading…
Reference in a new issue