Answer the question
In order to leave comments, you need to log in
How to distribute data between threads in python?
There is a base, as well as software that allows you to enter the number of threads. How can one distribute the database so that other threads do not touch the data that one of the threads has taken over?
Answer the question
In order to leave comments, you need to log in
ThreadPool. I did not come up with a more complicated function, I just deduce it for clarity.
from multiprocessing.dummy import Pool as ThreadPool
import os
data = [i for i in range(100)]
with ThreadPool(os.cpu_count() - 1) as tp:
tp.map(lambda x: print(x**2), data)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question