# http://stackoverflow.com/questions/323972/is-there-any-way-to-kill-a-thread-in-python ''' StoppableThread ''' # system imports from threading import Event, Thread # definitions class StoppableThread(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 = Event() def stop(self): self._stop.set() def stopped(self): return self._stop.isSet()