Clean up timer thread remove unnecessary is_running conditional check
Change-Id: I7bcba9d93ea7d9c1b2ed72ba142d021728fb7192
This commit is contained in:
parent
a6aee6794b
commit
26e39000c2
|
@ -43,19 +43,15 @@ class cpulseTimer(object):
|
||||||
self.function = function
|
self.function = function
|
||||||
self.args = args
|
self.args = args
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.is_running = False
|
|
||||||
self.start()
|
self.start()
|
||||||
|
|
||||||
def _run(self):
|
def _run(self):
|
||||||
self.is_running = False
|
|
||||||
self.start()
|
self.start()
|
||||||
self.function(self, *self.args, **self.kwargs)
|
self.function(self, *self.args, **self.kwargs)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
if not self.is_running:
|
self._timer = Timer(self.interval, self._run)
|
||||||
self._timer = Timer(self.interval, self._run)
|
self._timer.start()
|
||||||
self._timer.start()
|
|
||||||
self.is_running = True
|
|
||||||
|
|
||||||
|
|
||||||
def test_run(**kwargs):
|
def test_run(**kwargs):
|
||||||
|
|
Loading…
Reference in New Issue