[英]Why is multiprocessing hanging?
我第一次尝试使用以下代码使用多处理:
def fuzzy_match(blg_matches, op_matches):
update_dicts = []
with concurrent.futures.ProcessPoolExecutor() as executor:
scored_matches = [
executor.submit(run_matching, blg_match, repeat(op_matches))
for blg_match in blg_matches
]
for match in concurrent.futures.as_completed(scored_matches):
update_dicts.append(match)
return update_dicts
但是,它只是挂起,什么也不做。
为了测试,我将run_matching
function 剥离为:
def run_matching(blg_match, op_matches):
return 2
它仍然挂起。
blg_matches
和op_matches
都是 SQLAlchemy 查询对象。
关于我哪里出错的任何想法?
所以事实证明这里有两个问题。
if __name__ == "__main__":
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.