Enhanced Job Pool for Python Multiprocessing
from job_pool import JobPool
def add_one(i):
return i + 1
def multiprocessed_add_one():
pool = JobPool(4)
for i in range(20):
pool.applyAsync(add_one, [i])
results = pool.checkPool(printProgressEvery=5)
assert results == list(range(1,21))
job-pool is available on PyPI and can be installed with pip
:
pip install job-pool
Alternatively, you can install job-pool after cloning from this repository:
git clone https://github.com/matthewthe/job-pool.git
pip install .