There is a code:
username = 'ivan' parted_list = [[1],[2],[3],[4],[5],[6],[7],[8],[9],[10]] my_function(username,parted_list): print('yep!') p = multiprocessing.Pool() thread_number = 0 for i in range(10): work = p.map(lambda f: f(username,parted_list[thread_number]),[my_function]) thread_number +=1 p.close() p.join() What is the problem: the code works, but the threads are started in turn, due to the for loop In order for them to run in parallel, as I understand it, this line is necessary:
work = p.map(lambda f: f(username,parted_list[thread_number]),[my_function]) redo this:
work = p.map(lambda f: f(username,parted_list[thread_number]),[my_function,my_function,my_function,my_function,my_function,my_function,my_function,my_function,my_function,my_function]) and remove the for loop. BUT! for each function there must be a different thread_number , that without a cycle to get, I do not know how. Is there a solution to this problem? It is also desirable in Python Zen, not to write my_function 10 times, but to do it more concisely.