From 0e0e17b089a59e8e09bc769c69f714a1eeb64dcd Mon Sep 17 00:00:00 2001 From: James Smith Date: Tue, 19 May 2026 13:10:44 +0100 Subject: [PATCH] style: document cleanup now-capture and widen test sleep margin --- tests/test_utils.py | 4 ++-- utils/cleanup.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_utils.py b/tests/test_utils.py index f9ba56d..92353ea 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -81,9 +81,9 @@ class TestDataStoreCleanup: def test_cleanup_removes_expired_keeps_fresh(self): """Test that cleanup removes expired entries and keeps fresh ones.""" - store = DataStore(max_age_seconds=0.001, name="test") + store = DataStore(max_age_seconds=0.05, name="test") store.set("old", 1) - time.sleep(0.01) + time.sleep(0.06) store.set("new", 2) removed = store.cleanup() diff --git a/utils/cleanup.py b/utils/cleanup.py index 7f7d60c..1dea2e8 100644 --- a/utils/cleanup.py +++ b/utils/cleanup.py @@ -123,6 +123,7 @@ class DataStore: Returns: Number of entries removed """ + # Capture now once so both the scan and re-validation use the same cutoff. now = time.time() with self._lock: