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
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to