Keyboard interruptable blocking queue in Python
问题 It seems import Queue Queue.Queue().get(timeout=10) is keyboard interruptible (ctrl-c) whereas import Queue Queue.Queue().get() is not. I could always create a loop; import Queue q = Queue() while True: try: q.get(timeout=1000) except Queue.Empty: pass but this seems like a strange thing to do. So, is there a way of getting an indefinitely waiting but keyboard interruptible Queue.get()? 回答1: Queue objects have this behavior because they lock using Condition objects form the threading module.