Answer the question
In order to leave comments, you need to log in
How to organize multi-threaded requests for command execution in using Telegram bot?
Hello.
When the bot is used by different people at the same time, it works in turn.
From the beginning it processes the request of one, after the second.
If these are simple commands, then this is not noticeable, but there are commands in which scripts are written for execution, and until this script works, it does not take another command.
Python bot.
Found this but not sure if it's correct.
import threading
theVar = 1
class MyThread(threading.Thread):
def run ( self ):
global theVar
def listener(messages):
@bot.message_handler(commands=['script1'])
def handle_script1_request(message):
ip = message.text.split()[-1]
result = ssh.get_script1(ip)
bot.send_message(message.chat.id, result)
theVar = theVar + 1
for x in xrange ( 20 ):
MyThread().start()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question