Fixed argument expansion
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Pünkösd Marcell 2020-09-30 05:34:22 +02:00
parent 7ec2b3255d
commit d4e6feb083
2 changed files with 8 additions and 8 deletions

View File

@ -76,8 +76,8 @@ def main() -> None:
logging.basicConfig(stream=sys.stdout, format="%(asctime)s - %(name)s [%(levelname)s]: %(message)s",
level=logging.DEBUG if '--debug' in sys.argv else logging.INFO)
BirbnetesIoTPlatformStatusDriver.init()
listofabcsignaprocessors = (SoundSignalProcessor())
loopingtimer = LoopingTimer(function=timer_tick, args=[listofabcsignaprocessors], interval=config.TICK_INTERVAL)
listofabcsignaprocessors = [SoundSignalProcessor()]
loopingtimer = LoopingTimer(function=timer_tick, tick_args=listofabcsignaprocessors, interval=config.TICK_INTERVAL)
loopingtimer.start()
client = paho.mqtt.client.Client(userdata=Loudspeaker(config.ENEMY_SOUNDS), client_id=config.DEVICE_ID)

View File

@ -15,19 +15,19 @@ class LoopingTimer:
"""
Looping timer. Executes a function and repeates it in the given interval.
"""
def __init__(self, interval, function, *args, **kwargs):
def __init__(self, interval, function, tick_args=[], tick_kwargs={}):
"""
Initialize class
:param interval:
:param function:
:param args:
:param kwargs:
:param tick_args:
:param tick_kwargs:
"""
self._timer = None
self.interval = interval
self.function = function
self.args = args
self.kwargs = kwargs
self._tick_args = tick_args
self._tick_kwargs = tick_kwargs
self.is_running = False
self.start()
@ -38,7 +38,7 @@ class LoopingTimer:
"""
self.is_running = False
self.start()
self.function(*self.args, **self.kwargs)
self.function(*self._tick_args, **self._tick_kwargs)
def start(self) -> None:
"""