Python 字典列表上的多重处理

Pri*_*nar 5 python multithreading process multiprocessing python-2.7

我有一个字典列表。字典列表=[{'name' : 'bob', 'weight': 50}, {'name' : 'ramesh', 'weight': 60}]

我想同时处理两个字典

我应该为这个多处理进程使用什么?

Pri*_*nar 4

我尝试过使用多处理池

from multiprocessing.pool import ThreadPool as Pool

pool_size = 5 

def worker(item1, itme2):
    try:
        print(item1.get('weight'))
        print(itme2)
    except:
        print('error with item')

pool = Pool(pool_size)
items = [{'name' : 'bob', 'weight': 50}, {'name' : 'ramesh','weight': 60}]
for item in items:
    pool.apply_async(worker, (item, 'item2'))

pool.close()
pool.join()
Run Code Online (Sandbox Code Playgroud)