Как запустить 2 рабочих потока или цикла событий? Телебот
Решил сделать бота, который примет определенные параметры, после начнет отправлять сообщения по заданным параметрам (лицо, задержка, текст, время), но возникла проблема, пытаюсь запустить два eventloops, один из из них — это телебот-бесконечность в области для бота, который получает данные, а второй — тоже телебот-бесконечность, селективный, но для учетной записи клиента телеграммы, который будет выполнять функциональность бота. Моя последняя проблемная функция выглядит так:
def debug(message):
if message.text == "✅Yes":
bot.send_message(message.chat.id, "Let`s go!")
bot.send_message(message.from_user.id, message.from_user.id)
autoPost(message, user.count, user.text, user.delay)
elif message.text == "❌No":
msg = bot.send_message(
message.chat.id, "Returning to main menu...", reply_markup=markup)
bot.register_next_step_handler(msg, welcome)
Ошибка:
2022-05-25 21:16:20,277 (__init__.py:573 MainThread) ERROR - TeleBot: "Infinite polling exception: there is no current event loop in the 'WorkerThread2' thread'." 2022-05-25 21:16:20,278 (__ init__.py:575 MainThread) ERROR - TeleBot: "Exception Trace: Trace (last last call): File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py ", line 569, in infinity_polling self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout, File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py ", line 620, in the self.__threaded_polling survey(non_stop=non_stop, interval=interval, timeout=timeout, long_polling_timeout=long_polling_timeout, File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py ", line 694, in the file __threaded_polling raise e "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\__init__.py ", line 650, in the file __threaded_polling self.worker_pool.raise_exceptions() "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\util.py ", line 143, in the file raise_exceptions raise self.exception_info "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\util.py ", line 89, in the execute task(*arguments, **kwargs) file "C:\Users\Администратор\Desktop\workspace\python\autopost bot\main.py ", line 142, in debug autoPost(message, user.count, user.text, user.delay) File "C:\Users\Администратор\Desktop\workspace\python\autopost bot\main.py ", line 132, in the autoPost client.send_message file(entity, text) "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\telethon\sync.py ", line 35, in the file syncified loop = asyncio.get_event_loop() "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\asyncio\events.py ", line 656, an execution error is called in get_event_loop ('There is no current event loop in the %r thread.' Execution error: There is no current event loop in the 'WorkerThread2' thread.