Attaching a stream with any argument results in keyboard interrupt recognition

As noted several times , calling Thread.join () with no argument will wait for the thread to complete before throwing KeyboardInterrupt. The curious thing is that if you provide any argument at all, the connection will come into play immediately upon interruption (instead of waiting for the next timeout). Why is this?

# test.py

import threading

x = threading.Event()
def waitForever():
    x.wait()

t = threading.Thread(target = waitForever)
t.start()

try:
    t.join(float('inf'))
except KeyboardInterrupt:
    x.set()
    print "Killed"

      


$ python test.py 
^CKilled
$

      

+3


source to share





All Articles