擅长:python、mysql、java
<p><a href="https://docs.python.org/3/library/asyncio-task.html#future">^{<cd1>} documentation</a>涵盖了这些差异:</p>
<blockquote>
<p>class <code>asyncio.Future(*, loop=None)</code></p>
<p>This class is almost compatible with <code>concurrent.futures.Future</code>.</p>
<p>Differences:</p>
<ul>
<li><code>result()</code> and <code>exception()</code> do not take a timeout argument and raise an exception when the future isn’t done yet.</li>
<li>Callbacks registered with <code>add_done_callback()</code> are always called via the event loop’s <code>call_soon_threadsafe()</code>.</li>
<li>This class is not compatible with the <code>wait()</code> and <code>as_completed()</code> functions in the <code>concurrent.futures</code> package.</li>
</ul>
<p>This class is not thread safe.</p>
</blockquote>
<p>基本上,如果您正在使用<code>ThreadPoolExecutor</code>或<code>ProcessPoolExecutor</code>,或者希望直接使用<code>Future</code>进行基于线程或基于进程的并发,请使用<code>concurrent.futures.Future</code>。如果您使用的是<code>asyncio</code>,请使用<code>asyncio.Future</code>。</p>