mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-07-19 19:02:08 +08:00
debounce
This commit is contained in:
@@ -6,7 +6,7 @@ import tracemalloc
|
||||
from openpilot.common.params import Params
|
||||
from openpilot.common.params_pyx import UnknownKeyName
|
||||
|
||||
from openpilot.sunnypilot.common.param_watcher import ParamWatcher
|
||||
from openpilot.sunnypilot.common.param_watcher import ParamWatcher, IN_MODIFY
|
||||
|
||||
|
||||
class TestParamWatcher:
|
||||
@@ -82,10 +82,11 @@ class TestParamWatcher:
|
||||
def test_cache_invalidation_simulation(self, param_watcher):
|
||||
self.params.put(self.bytes_key, b"old")
|
||||
assert param_watcher.get(self.bytes_key) == b"old"
|
||||
time.sleep(0.2)
|
||||
|
||||
event = threading.Event()
|
||||
param_watcher.add_watcher(lambda key, mask: event.set())
|
||||
param_watcher._trigger_callbacks(self.bytes_key, 0) # mask=0 for simulation
|
||||
param_watcher._trigger_callbacks(self.bytes_key, IN_MODIFY)
|
||||
assert event.wait(timeout=2), "Callback not triggered"
|
||||
|
||||
self.params.put(self.bytes_key, b"new")
|
||||
|
||||
Reference in New Issue
Block a user