<p>有关<code>multiprocessing</code>{a1}的文档包括以下关于<code>Pool.join()</code>的内容:</p>
<blockquote>
<p>Wait for the worker processes to exit. One must call <code>close()</code> or <code>terminate()</code> before using <code>join()</code>.</p>
</blockquote>
<p>我知道<code>Pool.close()</code>会阻止任何其他任务提交到池中;并且<code>Pool.join()</code>在继续父进程之前等待池完成</p>
<p>那么,如果我想重用我的池来执行多个任务,然后在很久以后调用它,为什么我不能在<code>Pool.close()</code>之前调用<code>Pool.join()</code>?例如:</p>
<pre class="lang-py prettyprint-override"><code>pool = Pool()
pool.map(do1)
pool.join() # need to wait here for synchronization
.
.
.
pool.map(do2)
pool.join() # need to wait here again for synchronization
.
.
.
pool.map(do3)
pool.join() # need to wait here again for synchronization
pool.close()
# program ends
</code></pre>
<p>为什么<em>在使用<code>join()</code>之前必须</em>一次“调用<code>close()</code>或<code>terminate()</code>”</p>