Threading Keyboard Interrupt issue
nihar Modi
niharmodi712 at gmail.com
Wed May 29 04:38:51 EDT 2019
I have written a simple code that involves threading, but it does not go to
except clause after Keyboard interrupt. Can you suggest a way out. I have
pasted the code below. It does not print 'hi' after keyboard interrupt and
just stops.
import threading
def loop():
while true:
print('hello')
time.sleep(5)
if __name__ == '__main__':
try:
y = threading.Thread(target = loop, args = ())
y.start()
except KeyboardInterrupt:
print('hi')
The program does not print hi and terminates immediately after ctrl+c
More information about the Python-list
mailing list