在python中使用多处理池这就是我想要做的:
def do_task(data):
print "Executing: " + data
return data
def do_something(data):
print "Starting do_something"
result2 = pool.map_async(do_task, ["AA","BB"])
print "before get"
result2.get()
print "after get"
return data
def main():
pool = Pool(processes=4)
result = pool.apply_async(do_something, "A")
print result.get()
但它在这里的输出不起作用:
Starting do_something
before get
它停留在这里并且 do_task 永远不会被调用。有人能解释一下为什么吗?谢谢