Like this:
from joblib import effective_n_jobs
print(effective_n_jobs(-1))
pairwise_distances
uses Parallel under the hood; you can test it if you like:
from time import sleep
from joblib import Parallel, delayed
Parallel(n_jobs=-1, verbose=10)(delayed(sleep)(.2) for _ in range(10))
Output:
[Parallel(n_jobs=-1)]: Using backend LokyBackend with 12 concurrent workers.
[Parallel(n_jobs=-1)]: Done 3 out of 10 | elapsed: 0.6s remaining: 1.3s
[Parallel(n_jobs=-1)]: Done 5 out of 10 | elapsed: 0.6s remaining: 0.6s
[Parallel(n_jobs=-1)]: Done 7 out of 10 | elapsed: 0.6s remaining: 0.3s
[Parallel(n_jobs=-1)]: Done 10 out of 10 | elapsed: 0.6s finished
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…