The multiprocessing module
from multiprocessing import Pool
class Worker:
def __init__(self, ...):
pass
def __call__(self, item):
return item
with Pool() as pool:
worker = Worker(...) # pass additional data here
for result in pool.imap_unordered(worker, iterable):
pass