2
如何将多个参数传递给通过pool.map调用的函数?Python gevent:将多个参数传递给通过pool.map调用的函数
我的代码:
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
它可以看起来像' pool.map(解包(进程),作业)'。 如果你愿意,你可以投票给'funcy'库添加'unpack'装饰器。 https://github.com/Suor/funcy/pull/62 – ADR