lang:python:thread
Exécution de plusieurs fonctions en parallèle
import multiprocessing def f(e): print(e) return if __name__ == '__main__': # start 8 worker processes with multiprocessing.Pool(processes=8) as pool: # launching multiple evaluations asynchronously *may* use more processes multiple_results = [pool.apply_async(f, args=[i]) for i in range(1,66)] print([res.get(timeout=10000) for res in multiple_results])
lang/python/thread.txt · Dernière modification : 2020/09/23 07:35 de root