pool.imap_unordered() 和 pool.apply_async() 有什么区别?

What is the difference between pool.imap_unordered() and pool.apply_async()?

pool.imap_unordered()pool.apply_async()有什么区别?

何时 pool.imap_unordered() 优于 pool.apply_async() 或相反?

调用pool.apply_async(f, (1, 2, 3, 4))的结果是f(1, 2, 3, 4)会在某个线程中被调用。 apply_async 返回的值是一个 AsyncResult,您可以用它来等待结果。

调用pool.imap_unordered(f, (1, 2, 3, 4))的结果是一个迭代器。它 returns f(1)f(2)f(3)f(4) 的结果是未指定的顺序。