From 8cd9e9e35a9f844a2fb496d9bdefece09592cb3b Mon Sep 17 00:00:00 2001 From: deanlee Date: Mon, 9 Dec 2024 04:25:38 +0800 Subject: [PATCH] add configurable update interva --- common/parameter_updater.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/parameter_updater.py b/common/parameter_updater.py index bc9f3f0af47c9d..30885b790f6381 100644 --- a/common/parameter_updater.py +++ b/common/parameter_updater.py @@ -5,7 +5,7 @@ class ParameterUpdater: - def __init__(self, params_to_update: dict[str, str]): + def __init__(self, params_to_update: dict[str, str], update_interval: float = 0.1): """ params_to_update: A dictionary where keys are parameter names, and values are their types ('bool' or 'str'). Example: {"IsMetric": "bool", "LongitudinalPersonality": "str"} @@ -13,6 +13,7 @@ def __init__(self, params_to_update: dict[str, str]): self.params = Params() self.params_to_update = params_to_update self.param_values = {param: None for param in params_to_update} + self.update_interval = update_interval self._update() # Initial update @@ -50,4 +51,4 @@ def _update(self): def _update_periodically(self): while not self.stop_event.is_set(): self._update() - time.sleep(0.1) + time.sleep(self.update_interval)