Skip to content

Commit

Permalink
added stopthread
Browse files Browse the repository at this point in the history
  • Loading branch information
alicerr committed Apr 21, 2015
1 parent 9c7606f commit 5d7e1a7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions stopthread.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'''
Created on Mar 30, 2015
@author: Alice
'''
import threading
class StopThread(threading.Thread):
'''
classdocs
'''


def __init__(self, some_lambda_function):
super(StopThread, self).__init__()
self._stop = threading.Event()
self.job = some_lambda_function

def stop(self):
self._stop.set()

def stopped(self):
return self._stop.isSet()


def run(self):
while not self._stop.isSet():
self.job()
print "thread executed"

0 comments on commit 5d7e1a7

Please sign in to comment.