mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2025-12-06 07:12:04 +01:00
some little fixes
This commit is contained in:
parent
7d2935ea0d
commit
3eac36d123
|
|
@ -66,13 +66,17 @@ class RepeatedTimer:
|
|||
"""!Stop the timer worker thread
|
||||
|
||||
@return True or False"""
|
||||
self._event.set()
|
||||
if self._thread is not None:
|
||||
logging.debug("stop repeatedTimer: %s", self._thread.name)
|
||||
self._thread.join()
|
||||
try:
|
||||
self._event.set()
|
||||
if self._thread is not None:
|
||||
logging.debug("stop repeatedTimer: %s", self._thread.name)
|
||||
self._thread.join()
|
||||
return True
|
||||
logging.warning("repeatedTimer always stopped")
|
||||
return True
|
||||
logging.warning("repeatedTimer always stopped")
|
||||
return False
|
||||
except: # pragma: no cover
|
||||
logging.exception("cannot stop repeatedTimer")
|
||||
return False
|
||||
|
||||
def _target(self):
|
||||
"""!Runs the target function with his arguments in own thread"""
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ class Test_Timer:
|
|||
self.testTimer = RepeatedTimer(0.1, Test_Timer.testTargetFast)
|
||||
yield 1 # server the timer instance
|
||||
if self.testTimer.isRunning:
|
||||
self.testTimer.stop()
|
||||
assert self.testTimer.stop()
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def useTimerSlow(self):
|
||||
|
|
@ -53,7 +53,7 @@ class Test_Timer:
|
|||
self.testTimer = RepeatedTimer(0.1, Test_Timer.testTargetSlow)
|
||||
yield 1 # server the timer instance
|
||||
if self.testTimer.isRunning:
|
||||
self.testTimer.stop()
|
||||
assert self.testTimer.stop()
|
||||
|
||||
# test cases starts here
|
||||
|
||||
|
|
@ -61,13 +61,13 @@ class Test_Timer:
|
|||
assert self.testTimer.start()
|
||||
assert self.testTimer.stop()
|
||||
|
||||
def test_timerDoubleSTart(self, useTimerFast):
|
||||
def test_timerDoubleStart(self, useTimerFast):
|
||||
assert self.testTimer.start()
|
||||
assert self.testTimer.start()
|
||||
assert self.testTimer.stop()
|
||||
|
||||
def test_timerStopNotStarted(self, useTimerFast):
|
||||
assert not self.testTimer.stop()
|
||||
assert self.testTimer.stop()
|
||||
|
||||
def test_timerIsRunning(self, useTimerFast):
|
||||
assert self.testTimer.start()
|
||||
|
|
|
|||
Loading…
Reference in a new issue