I was trying to use Thread
of Python to parallelize my code but I ran into a problem: when I command to create the threads, the amount of them exceeds 1,000 Threads easily, which, from 140, all begin to give error.
Searching a bit I found joblib
, but I did not find any examples of how to use it with my functions ... For example, I want a function, created by me, that has 3 parameters, and this function is inside a for, which will be repeated thousands of times ...
repeticoes = 10000
for i in range(repeticoes):
minha_funcao(data[i], top, param3)
Would I use it like this?
from joblib import Parallel, delayed
Parallel(n_jobs=4, verbose=1)(delayed(minha_funcao)(data[i], top, param3) for i in range(repeticoes))