擅长:python、mysql、java
<p>如果使用的是<a href="http://docs.python.org/library/queue.html?highlight=queue#Queue.Queue" rel="nofollow">^{<cd1>}</a>,则可以使用可选的<code>block</code>和{<cd4>}参数调用{a2},或者调用{<cd5>},它相当于<code>Queue.get(block=False)</code>,如果队列为空,它将立即返回:</p>
<pre><code>try:
# wait for 1/10 second then return
msgs = self.msgQ.get(timeout=0.1)
except Queue.Empty, qe:
# handle empty queue
</code></pre>