This issue probably depends on #1167930 When waiting on a queue in blocking mode, in no timeout is set, ctrl-C doesn't raise KeyboardInterrupt:: q = Queue() q.get(True) # ctrl-c doesn't work here If any timeout is set, ctrl-c works as expected:: q = Queue() ONEYEAR = 365 * 24 * 60 * 60 q.get(True, ONEYEAR) # ctrl-c works here Traceback (most recent call last): File "queuebug.py", line 6, in q.get(True, ONEYEAR) File "/usr/lib/python2.5/Queue.py", line 174, in get self.not_empty.wait(remaining) File "/usr/lib/python2.5/threading.py", line 233, in wait _sleep(delay) KeyboardInterrupt
This (and the other issue you mention) is because the regular acquire() method on a basic lock cannot be interrupted. That's unlikely to go away, so you'll just have to live with this. As you've discovered, specifying a timeout solves the issue. Since code running in threads doesn't receive signals anyway (in Python), it would be fairly pointless to slow down lock acquisition in order to support keyboard interrupts.
Because the easy workaround, we can live with the issue. Anyway, because the workaround is not trivial to find, and because the behavior is supposed to remain unchanged, maybe the issue should be mentioned in the docs. Thank you for the explanation :)
Can a note be added to the Queue.get() documentation? This behavior has been known to be at least potentially confusing for a decade, and there's no mention of it in the documentation.