How do I pass multiple arguments to a function I call through pool.map?
My code:
import gevent
from gevent.pool import Pool
def process(param1, param2):
return "dosomething"
pool = Pool(10)
jobs = [('arg1a', 'arg1b'), ('arg2a', 'arg2b')]
# should pass arguments so that it results in these calls
# process(param1=arg1a, param2=arg1b)
# process(param1=arg2a, param2=arg2b)
results = pool.map(process, jobs) # does not work
It appears the
gevent.Pool.mapmethod only allows a single item to be passed as an argument to the function you provide. However, you can code the function to unpack its arguments pretty easily:Or you could handle the argument unpacking with a lambda expression right in your call to
pool.map: