<p>Jarret Hardie已经<a href="https://stackoverflow.com/questions/631441/interruptible-thread-join-in-python/631605#631605">mentioned it</a>:根据<a href="http://bugs.python.org/msg56947" rel="nofollow noreferrer">Guido van Rossum</a>,目前没有更好的方法:如<a href="http://docs.python.org/library/threading.html#threading.Thread.join" rel="nofollow noreferrer">documentation</a>,<code>join(None)</code>块中所述(这意味着没有信号)。另一种方法是用一个巨大的超时(<code>join(2**31)</code>)调用并检查<code>isAlive</code>看起来很棒。然而,Python处理计时器的方式是灾难性的,在使用<code>servth.join(100)</code>而不是<code>servth.join()</code>运行Python测试程序时可以看到:</p>
<pre><code>select(0, NULL, NULL, NULL, {0, 1000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 2000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 4000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 8000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 16000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 32000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
select(0, NULL, NULL, NULL, {0, 50000}) = 0 (Timeout)
--- Skipped 15 equal lines ---
select(0, NULL, NULL, NULL, {0, 50000}Killing
</code></pre>
<p>也就是说,Python每50毫秒唤醒一次,导致单个应用程序无法让CPU休眠。</p>