I have created a pool from the python multiprocessing module and would like to change the number of processes that the pool has running or add to them. Is this possible? I have tried something like this (simplified version of my code)
class foo:
def __init__():
self.pool = Pool()
def bar(self, x):
self.pool.processes = x
return self.pool.map(somefunction, list_of_args)
It seems to work and achieves the result I wanted in the end (which was to split the work between multiple processes) but I am not sure that is this the best way to do it, or why it works.