Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class StoppableThread(threading.Thread):
- """Thread class with a stop() method. The thread itself has to check
- regularly for the stopped() condition."""
- def __init__(self):
- super(StoppableThread, self).__init__()
- self._stop = threading.Event()
- print "qqwop"
- threading.Timer(3.0, StoppableThread).start()
- def stop(self):
- self._stop.set()
- def stopped(self):
- return self._stop.isSet()
- StoppableThread()
- time.sleep(6)
- print "die!"
- hej = StoppableThread()
- hej.terminate()
Add Comment
Please, Sign In to add comment