From f0bfe76747ce297e1f5e273b213c81636eafa4e1 Mon Sep 17 00:00:00 2001 From: josh-deb Date: Fri, 18 Oct 2024 18:26:59 -0700 Subject: [PATCH] chore: good nits --- beams/behavior_tree/ActionNode.py | 3 ++- beams/behavior_tree/ActionWorker.py | 12 +++++------- beams/sequencer/helpers/Timer.py | 6 +++--- beams/tests/test_timer.py | 2 ++ 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/beams/behavior_tree/ActionNode.py b/beams/behavior_tree/ActionNode.py index 0599aa8..647d3d0 100644 --- a/beams/behavior_tree/ActionNode.py +++ b/beams/behavior_tree/ActionNode.py @@ -5,7 +5,8 @@ import py_trees -from beams.behavior_tree.ActionWorker import ActionWorker, wrapped_action_work # the latter is grabbed as a pas through +from beams.behavior_tree.ActionWorker import wrapped_action_work # noqa: F401 +from beams.behavior_tree.ActionWorker import ActionWorker from beams.behavior_tree.VolatileStatus import VolatileStatus from beams.typing_helper import ActionNodeWorkLoop, Evaluatable diff --git a/beams/behavior_tree/ActionWorker.py b/beams/behavior_tree/ActionWorker.py index e68b940..3cf7879 100644 --- a/beams/behavior_tree/ActionWorker.py +++ b/beams/behavior_tree/ActionWorker.py @@ -13,19 +13,18 @@ """ import logging import time -from multiprocessing import Event, Value, Queue +from multiprocessing import Event, Queue, Value from typing import Callable, Optional -from epics.multiproc import CAProcess - import py_trees +from epics.multiproc import CAProcess from beams.behavior_tree.VolatileStatus import VolatileStatus from beams.logging import LOGGER_QUEUE, worker_logging_configurer +from beams.sequencer.helpers.Timer import Timer +from beams.sequencer.helpers.Worker import Worker from beams.typing_helper import (ActionNodeWorkFunction, ActionNodeWorkLoop, Evaluatable) -from beams.sequencer.helpers.Worker import Worker -from beams.sequencer.helpers.Timer import Timer logger = logging.getLogger(__name__) @@ -51,8 +50,7 @@ def work_wrapper( log_configurer(log_queue) work_loop_timeout_timer = Timer(name=name, timer_period_seconds=work_function_timeout_period_sec, - auto_start=False, - is_periodic=True) + auto_start=False) while (do_work.value): logger.debug(f"WAITING FOR INIT from node: {name}") work_gate.wait() diff --git a/beams/sequencer/helpers/Timer.py b/beams/sequencer/helpers/Timer.py index 0bee866..c1dbe1d 100644 --- a/beams/sequencer/helpers/Timer.py +++ b/beams/sequencer/helpers/Timer.py @@ -3,16 +3,16 @@ class Timer(): def __init__(self, - name: str, + name: str, timer_period_seconds: float, - auto_start: bool = False, + auto_start: bool = False, is_periodic: bool = False): self.name = name self.timer_period_seconds = timer_period_seconds self.is_periodic = is_periodic self.auto_start = auto_start if (self.auto_start): - self.timer_start_time = time.time() + self.timer_start_time = time.monotonic() else: self.timer_start_time = -1 diff --git a/beams/tests/test_timer.py b/beams/tests/test_timer.py index ac12f21..9542b04 100644 --- a/beams/tests/test_timer.py +++ b/beams/tests/test_timer.py @@ -1,5 +1,7 @@ import time + import pytest + from beams.sequencer.helpers.Timer import Timer