Most examples of the Multiprocess Worker Pools execute a single function in different processes, f.e.
def foo(args):
pass
if __name__ == '__main__':
pool = multiprocessing.Pool(processes=30)
res=pool.map_async(foo,args)
Is there a way to handle two different and independent functions within the pool? So that you could assign f.e. 15 processes for foo() and 15 processes for bar() or is a pool bounded to a single function? Or du you have to create different processes for different functions manually with
p = Process(target=foo, args=(whatever,))
q = Process(target=bar, args=(whatever,))
q.start()
p.start()
and forget about the worker pool?
To pass different functions, you can simply call
map_asyncmultiple times.Here is an example to illustrate that,
The result will be: