Fix unit tests

This commit is contained in:
Gina Häußge committed 2018-09-26 15:52:10 +02:00
1 parent f32ea65b2c
commit 5ff790048d
3 files changed
+23 -2

No files matched your search

+4 -1
View File
@@ -1270,8 +1270,9 @@ class ResettableTimer(threading.Thread):
class CountedEvent(object):
def __init__(self, value=0, maximum=None, **kwargs):
def __init__(self, value=0, minimum=0, maximum=None, **kwargs):
self._counter = 0
self._min = minimum
self._max = kwargs.get("max", maximum)
self._mutex = threading.RLock()
self._event = threading.Event()
@@ -1313,6 +1314,8 @@ class CountedEvent(object):
def _internal_set(self, value):
self._counter = value
if self._counter <= 0:
if self._min is not None and self._counter < self._min:
self._counter = self._min
self._event.clear()
else:
if self._max is not None and self._counter > self._max:
+1 -1
View File
@@ -479,7 +479,7 @@ class MachineCom(object):
self._long_running_commands = settings().get(["serial", "longRunningCommands"])
self._checksum_requiring_commands = settings().get(["serial", "checksumRequiringCommands"])
self._clear_to_send = CountedEvent(name="comm.clear_to_send")
self._clear_to_send = CountedEvent(name="comm.clear_to_send", minimum=None)
self._send_queue = SendQueue()
self._temperature_timer = None
self._sd_status_timer = None