📜  python 2.7 多线程 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:16.920000             🧑  作者: Mango

代码示例1
from multiprocessing.pool import ThreadPool as Pool

pool_size = 10
pool = Pool(pool_size)

results = []

for region, directory_ids in direct_dict.iteritems():
    for dir in directory_ids:
        result = pool.apply_async(describe_with_directory_workspaces,
                                  (region, dir, username))
        results.append(result)

for result in results:
    code, content = result.get()
    if code == 0:
        # ...