1

I am faced with the following problem, I have several bots and a module that monitors their status. There are different threads for the bot and for monitoring. But I came across the fact that the telebot api returns an error to the console

2022-02-17 23:38:05,701 (init.py:688 Thread-2) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running" 2022-02-17 23:38:09,023 (init.py:688 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. Error code: 409. Description: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"

that is, the polling bot is launched simultaneously in the main thread and in its own This is the code that runs the bot and the monitoring module


def bot_boling():
    tb.polling(none_stop=True, interval=1)

send_heart_bit_thread = Thread(target=send_heart_bit, daemon=True)
bot_polling_thread = Thread(target=bot_boling, daemon = True)
send_heart_bit_thread.start()
bot_polling_thread.start()
bot_polling_thread.run()
send_heart_bit_thread.run()

I would like to understand why the polling bot is seen in the main thread. and can I make it so that this does not happen, or define the thread for the bot's polling as the main one, so that when this thread is closed, the entire script is closed

0 Answers0