00001 #!/usr/bin/env python 00002 #import zmq 00003 import signal 00004 00005 interrupted = False 00006 00007 def signal_handler(signum, frame): 00008 global interrupted 00009 print 'Ctrl Pressed!' 00010 interrupted = True 00011 counter = 0 00012 f = 1/float(2) 00013 print "%.4f" % f 00014 signal.signal(signal.SIGINT, signal_handler) 00015 while True: 00016 # print 'hello' 00017 counter += 1 00018 if interrupted: 00019 print 'hello' 00020 break