G
G
GotLib12021-07-28 20:35:41
Python
GotLib1, 2021-07-28 20:35:41

How to run a script for multiple users at the same time?

I have a script that is combined with a telegram bot. The user enters certain data into the bot, they are filled in the database, after that main.py is launched, in which a file is imported with the main functionality for filling data on the site, which are taken from the same database. I plan to put the bot on the server.

Question: let's say a couple of people want to use the bot at the same time. How to run the script so that the data of each user is filled in parallel to each other?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gennady S, 2021-07-28
@gscraft

If I understood your problem correctly, then no additional efforts are needed, the data of each user will be filled in parallel to each other. Unless, of course, you have problems with the database configuration, with multi-threaded operation of the server application and with single-threaded connection in the application, for example. Otherwise, the entire network works like this: users initiate the work of various storages, which, in turn, quietly write data in parallel. It is more difficult to decide just the opposite: to exclude the simultaneous overwriting of related data or not to perform the same work repeatedly. If you just want to solve this problem so that many users have access to one data resource, use locks, transactions. Well, or rethink the application architecture / data structure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question