Communicating end of Queue
问题 I'm learning to use the Queue module, and am a bit confused about how a queue consumer thread can be made to know that the queue is complete. Ideally I'd like to use get() from within the consumer thread and have it throw an exception if the queue has been marked "done". Is there a better way to communicate this than by appending a sentinel value to mark the last item in the queue? 回答1: original (most of this has changed; see updates below) Based on some of the suggestions (thanks!) of Glenn