python gevent使用例子
from gevent.pool import Pool POOL_SIZE = 100 def process(func, param1_list, param2_list)
stat = {}
pool = Pool(POOL_SIZE)
results = pool.imap_unordered(func, param1_list, param2_list)
pool.join()
# 处理结果
for value in results:
stat.update(value)
return stat def add(a, b):
return {a: a+b} print(process(add, [1,2,3], [3,4,5]))
# {1: 4, 2: 6, 3: 8}