擅长:python、mysql、java
<p>除非调用<a href="http://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.AsyncResult" rel="noreferrer">^{<cd2>}</a>的<a href="http://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.AsyncResult.get" rel="noreferrer">^{<cd1>} method</a>(返回值<code>apply_async</code>),否则不会引发错误:</p>
<p>根据<a href="http://docs.python.org/2/library/multiprocessing.html#multiprocessing.pool.AsyncResult.get" rel="noreferrer">^{<cd4>} documentation</a>:</p>
<blockquote>
<p>Return the result when it arrives. If timeout is not None and the
result does not arrive within timeout seconds then
multiprocessing.TimeoutError is raised. <strong>If the remote call raised an
exception then that exception will be reraised by get()</strong>.</p>
</blockquote>
<pre><code>def pool():
pool = mp.Pool(processes=1)
result = pool.apply_async(worker, args=())
result.get() # <------------
pool.close()
pool.join()
print "Multiprocessing done!"
</code></pre>