fix timeouts?

This commit is contained in:
Tomáš Mládek 2018-04-26 18:03:28 +02:00 committed by Tomáš Mládek
parent cb25c2baf3
commit 77f3c2fc10

View file

@ -118,8 +118,6 @@ def handle_hashtag(bot, update):
# noinspection PyBroadException # noinspection PyBroadException
def handle(urls, message, download, filename=None): def handle(urls, message, download, filename=None):
tries = 0
while tries < 3:
try: try:
logger.info("Downloading %s" % urls) logger.info("Downloading %s" % urls)
hashtag = get_first_hashtag(message) hashtag = get_first_hashtag(message)
@ -141,16 +139,10 @@ def handle(urls, message, download, filename=None):
hashtag or '.', message.date, hashtag or '.', message.date,
extract=(hashtag == 'AUDIO'), extract=(hashtag == 'AUDIO'),
filename=filename) filename=filename)
break
except: except:
_, exc_value, __ = sys.exc_info() _, exc_value, __ = sys.exc_info()
if "Timed out" not in str(exc_value): if "Timed out" not in str(exc_value):
message.reply_text("Something is FUCKED: %s" % exc_value) message.reply_text("Something is FUCKED: %s" % exc_value)
break
else:
tries += 1
if tries == 3:
message.reply_text("Something is FUCKED, tried thrice and it's all wrong")
def handle_url(bot, update): def handle_url(bot, update):
@ -189,6 +181,11 @@ def start(bot, update):
def error(bot, update, error): def error(bot, update, error):
logger.error(error) logger.error(error)
if "Timed out" in error:
if update is not None:
update.message.reply_text("Now for realz tho")
handle_rest(bot, update)
else:
if update is not None: if update is not None:
update.message.reply_text("Something is fucked: %s" % error) update.message.reply_text("Something is fucked: %s" % error)