一個線程中這就是我想要做的事:調用map_async使用蟒蛇 多處理池不工作
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永遠不會被調用。有人解釋我爲什麼? 謝謝
那麼,你永遠不會叫'do_task' – Dikei
抱歉編輯錯誤 – Johny19