Skip to content

The agent that grows with you

fix(gateway): ThreadParticipationTracker.clear() takes the lock

kshitijk4poorf8be6db187f9
diff --git a/gateway/platforms/helpers.py b/gateway/platforms/helpers.py
index 38eb58dd599..6d439098902 100644
--- a/gateway/platforms/helpers.py
+++ b/gateway/platforms/helpers.py
@@ -181,7 +181,8 @@ class ThreadParticipationTracker:
return thread_id in self._threads
def clear(self) -> None:
- self._threads.clear()
+ with self._lock:
+ self._threads.clear()
def redact_phone(phone: str) -> str:
diff --git a/gateway/sticker_cache.py b/gateway/sticker_cache.py
index 409581077d0..24c71b20dc9 100644
--- a/gateway/sticker_cache.py
+++ b/gateway/sticker_cache.py
@@ -42,9 +42,10 @@ def _save_cache(cache: dict) -> None:
atomic_json_write(_resolve_cache_path(), cache)
-# Serializes the read-modify-write in ``cache_sticker_description``. Re-entrant
-# because the async wrapper dispatches straight into the sync form.
-_CACHE_LOCK = threading.RLock()
+# Serializes the read-modify-write in ``cache_sticker_description``. Nothing
+# re-acquires it while held (the async wrapper only dispatches the sync form
+# to a worker thread), so a plain Lock suffices.
+_CACHE_LOCK = threading.Lock()
def get_cached_description(file_unique_id: str) -> Optional[dict]: