I'm writing my first bot in Python in VSCode. I tested it by running it through the VSCode interface (I did not run it on the server). But from time to time the following error began to appear:
telebot.apihelper.ApiTelegramException: 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
The error occurs when I stop execution through the interface with the stop button, but the bot continues to work. Because of this, it is not possible to run the already corrected version of the code next time, since the previous execution of the bot has not been stopped. The VSCode interface shows that nothing is running, but in Telegram the previous version of the bot continues to work and respond to commands.
Please tell me how to forcefully terminate the bot program execution process?
Rebooted the computer. After rebooting the computer, the bot continues to work. Is there some kind of terminal command to interrupt pethon or some other solution?
Requested a new bot token from botfather. After changing the token in botfather, the program with the new token runs correctly. But the vscode output now shows an error periodically even when I don't run any code:
telebot.apihelper.ApiTelegramException: A request to the Telegram API was unsuccessful. Error code: 401. Description: Unauthorized
I understand that it occurs because the old process with the old token is still trying to execute.
Looks like I found a solution. Added a command to the bot that calls bot.stop_polling()