title: How to stop this running threading.Thread?
body: <p>I found this <strong>non blocking code</strong> on stack overflow which is <strong>using threads to provide functionality of nonblocking setInterval function in JavaScript</strong>. But when I try to stop the process it doesn't even the Ctrl + C is not stopping it, I have tried some more methods too stop the process but they are not working.
  Can someone please tell a right way to stop the process, thank you in advance.</p>
  <p>here is the code</p>
  <pre><code>import threading
  
  class ThreadJob(threading.Thread):
      def __init__(self,callback,event,interval):
          '''runs the callback function after interval seconds
  
          :param callback:  callback function to invoke
          :param event: external event for controlling the update operation
          :param interval: time in seconds after which are required to fire the callback
          :type callback: function
          :type interval: int
          '''
          self.callback = callback
          self.event = event
          self.interval = interval
          super(ThreadJob,self).__init__()
  
      def run(self):
          while not self.event.wait(self.interval):
              self.callback()
  
  
  
  event = threading.Event()
  
  def foo():
      print (&quot;hello&quot;)
  
  def boo():
      print (&quot;fello&quot;)
  
  
  
  def run():
      try:
          k = ThreadJob(foo,event,2)
          d = ThreadJob(boo,event,6)
          k.start()
          d.start()
          while 1:
              falg = input(&quot;Press q to quit&quot;)
              if(falg == 'q'):
                  quit()
                  return 
      except KeyboardInterrupt:
          print('Stoping the script...')         
      except Exception as e:
          print(e)
  
  run()
  print( &quot;It is non-blocking&quot;)
  </code></pre>