Guest User

Untitled

a guest
Apr 20th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. class StoppableThread(threading.Thread):
  2.     """Thread class with a stop() method. The thread itself has to check
  3.    regularly for the stopped() condition."""
  4.  
  5.     def __init__(self):
  6.         super(StoppableThread, self).__init__()
  7.         self._stop = threading.Event()
  8.         print "qqwop"
  9.         threading.Timer(3.0, StoppableThread).start()
  10.  
  11.     def stop(self):
  12.         self._stop.set()
  13.  
  14.     def stopped(self):
  15.         return self._stop.isSet()
  16.    
  17. StoppableThread()
  18.  
  19. time.sleep(6)
  20. print "die!"
  21. hej = StoppableThread()
  22. hej.terminate()
Add Comment
Please, Sign In to add comment