Skip to content

Commit

Permalink
add configurable update interva
Browse files Browse the repository at this point in the history
  • Loading branch information
deanlee committed Dec 8, 2024
1 parent ff659a1 commit 8cd9e9e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions common/parameter_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@


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"}
"""
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

Expand Down Expand Up @@ -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)

0 comments on commit 8cd9e9e

Please sign in to comment.