本文整理汇总了Python中multiprocessing.Pool.wait方法的典型用法代码示例。如果您正苦于以下问题:Python Pool.wait方法的具体用法?Python Pool.wait怎么用?Python Pool.wait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiprocessing.Pool
的用法示例。
在下文中一共展示了Pool.wait方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import wait [as 别名]
def main():
args = get_args()
start = time()
with open(args.output, 'w') as f:
wids = [line.strip() for line in
open(args.input).readlines()[:args.number]]
mapped = Pool(processes=8).map_async(identify_worker, wids)
mapped.wait()
print >> f, '\n'.join([x.encode('utf-8') for x in mapped.get()])
end = time()
total = end - start
print '%d seconds elapsed' % total
示例2: ListDocIdsService
# 需要导入模块: from multiprocessing import Pool [as 别名]
# 或者: from multiprocessing.Pool import wait [as 别名]
if details is not None:
url = details.get('url')
lang = details.get('lang')
#print url
#doc_ids = ListDocIdsService().get_value(wid)
doc_ids = map(lambda x: x.split('_')[1],
filter(lambda y: '_' in y,
#ListDocIdsService().get_value(wid)))[:100]
ListDocIdsService().get_value(wid)))
#pprint(doc_ids); sys.exit(0)
#for n in range(0, len(doc_ids), step):
##for n in range(0, 20, step):
# print 'n = %d' % n
# doc_ids_subset = doc_ids[n:n+step]
r = Pool(processes=8).map_async(get_fields, chunks(doc_ids, step))
r.wait()
pprint(r.get())
print '*'*80
#for k in r.get(): # DEBUG
# print k
fields = []
m = map(lambda x: fields.extend(x), r.get())
#pprint(fields)
indexed = dict(fields)
pprint(indexed) # DEBUG
#for doc_id in doc_ids_to_heads:
# entity_response = doc_ids_to_entities.get(
# doc_id, {'titles': [], 'redirects': {}})
# doc_ids_combined[doc_id] = map(preprocess,