S
S
sumi3sew2019-03-19 01:22:48
Python
sumi3sew, 2019-03-19 01:22:48

Why doesn't the bot 'serve' new users after two active users?

There is a tg bot to which the user sends 2 variables, the bot writes them to the database and after pressing the 'START' button creates a new one on the method, passing the data entered by the user

if message.text == 'START':
     var1 = 10
     var2 = 'asdasdads'
     thr = Thread(target = generate(var1, var2))

def generate(a,b):
     #вычисления

This calculation can take a very long time.
Everything works as it should:
the first user enters data, launches, calculations take place. At the same time, the second user does the same, everything works for him the same way.
But the third user will no longer have a single bot command working while the first two are performing calculations. And when one of the calculations stops, only then the bot will process all the commands sent by the third user.
I suspect something is wrong with the streams. In other parts of the code, it's just writing the entered messages into variables and displaying the answers, I did not set any restrictions in "2 active users".
Thanks to everyone who advises :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Chichak, 2019-03-28
@ilya_chch

Let me suggest that you use RQ or something similar to handle long-running requests.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question