# Method threading.Thread.join() has a bug which prevents it from releasing # a Lock when it is interrupted by a KeyboardInterrupt. This fixes it, # though it might have undesirable side-effects. class Thread(threading.Thread): def join(self, timeout=None): try: super(Thread, self).join(timeout) finally: try: self.__block.release() except: # we might not actually own it, so ignore errors here... pass