<p>打电话给<a href="http://docs.python.org/3.3/library/concurrent.futures.html#concurrent.futures.Executor.shutdown">^{<cd1>}</a>:</p>
<blockquote>
<p><strong><code>shutdown(wait=True)</code></strong></p>
<p>Signal the executor that it should free any resources that it is
using <em>when the currently pending futures are done executing</em>. Calls
to <code>Executor.submit()</code> and <code>Executor.map()</code> made after shutdown will
raise <code>RuntimeError</code>.</p>
<p>If wait is <code>True</code> then this method will not return until all the pending futures are
done executing and the resources associated with the executor have been freed.</p>
</blockquote>
<p>但是,如果您在一个列表中跟踪您的未来,那么您可以避免使用<a href="http://docs.python.org/3.3/library/concurrent.futures.html#concurrent.futures.wait">^{<cd2>}</a>函数关闭executor以备将来使用:</p>
<blockquote>
<p><strong><code>concurrent.futures.wait(fs, timeout=None, return_when=ALL_COMPLETED)</code></strong></p>
<p>Wait for the <code>Future</code> instances (possibly created by different
<code>Executor</code> instances) given by <code>fs</code> to complete. Returns a named 2-tuple
of sets. The first set, named done, contains the futures that
completed (finished or were cancelled) before the wait completed. The
second set, named not_done, contains uncompleted futures.</p>
</blockquote>
<p>请注意,如果您不提供<code>timeout</code>,它将一直等到所有未来完成。</p>
<p>您也可以使用<a href="http://docs.python.org/3.3/library/concurrent.futures.html#concurrent.futures.as_completed">^{<cd4>}</a>代替,但是您必须迭代它。</p>