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():
|
def thread_supervisor():
|
||||||
while True:
|
while True:
|
||||||
for uid in vk_tokens.scan_iter():
|
for uid in vk_tokens.scan_iter():
|
||||||
if check_thread(uid.decode("utf-8")):
|
tries = 0
|
||||||
try:
|
while check_thread(uid.decode("utf-8")):
|
||||||
create_thread(uid.decode("utf-8"), vk_tokens.get(uid))
|
if tries < 6:
|
||||||
except requests.exceptions.ReadTimeout as e:
|
try:
|
||||||
time.sleep(10)
|
create_thread(uid.decode("utf-8"), vk_tokens.get(uid))
|
||||||
time.sleep(120)
|
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)
|
supervisor = threading.Thread(name='supervisor', target=thread_supervisor)
|
||||||
|
@ -26,8 +26,9 @@ class VkPolling:
|
|||||||
updates = vk_user.get_new_messages()
|
updates = vk_user.get_new_messages()
|
||||||
if updates:
|
if updates:
|
||||||
handle_updates(vk_user, bot, chat_id, updates)
|
handle_updates(vk_user, bot, chat_id, updates)
|
||||||
except requests.exceptions.ReadTimeout as e:
|
except requests.exceptions.ReadTimeout:
|
||||||
logging.warning('Retrying VK Polling in {} seconds.'.format(int(timeout / 10)))
|
logging.warning('Retrying VK Polling.')
|
||||||
|
timeout = 0
|
||||||
for i in range(timeout):
|
for i in range(timeout):
|
||||||
if self._running:
|
if self._running:
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user