Final version of stability update
This commit is contained in:
parent
336b84436c
commit
faa580e861
20
bot.py
20
bot.py
@ -216,12 +216,20 @@ def check_thread(uid):
|
||||
def thread_supervisor():
|
||||
while True:
|
||||
for uid in vk_tokens.scan_iter():
|
||||
if check_thread(uid.decode("utf-8")):
|
||||
try:
|
||||
create_thread(uid.decode("utf-8"), vk_tokens.get(uid))
|
||||
except requests.exceptions.ReadTimeout as e:
|
||||
time.sleep(10)
|
||||
time.sleep(120)
|
||||
tries = 0
|
||||
while check_thread(uid.decode("utf-8")):
|
||||
if tries < 6:
|
||||
try:
|
||||
create_thread(uid.decode("utf-8"), vk_tokens.get(uid))
|
||||
except:
|
||||
tries = tries + 1
|
||||
else:
|
||||
mark = types.InlineKeyboardMarkup()
|
||||
login = types.InlineKeyboardButton('ВХОД', url=link)
|
||||
mark.add(login)
|
||||
bot.send_message(uid.decode("utf-8"), '<b>Непредвиденная ошибка, требуется повторный логин ВК!</b>',
|
||||
parse_mode='HTML', reply_markup=mark)
|
||||
time.sleep(60)
|
||||
|
||||
|
||||
supervisor = threading.Thread(name='supervisor', target=thread_supervisor)
|
||||
|
@ -26,8 +26,9 @@ class VkPolling:
|
||||
updates = vk_user.get_new_messages()
|
||||
if updates:
|
||||
handle_updates(vk_user, bot, chat_id, updates)
|
||||
except requests.exceptions.ReadTimeout as e:
|
||||
logging.warning('Retrying VK Polling in {} seconds.'.format(int(timeout / 10)))
|
||||
except requests.exceptions.ReadTimeout:
|
||||
logging.warning('Retrying VK Polling.')
|
||||
timeout = 0
|
||||
for i in range(timeout):
|
||||
if self._running:
|
||||
time.sleep(0.1)
|
||||
|
Loading…
x
Reference in New Issue
Block a user