Clean up compute lock after use to avoid memory leak
(self, key: str)
| 153 | return self._compute_locks[key] |
| 154 | |
| 155 | def _cleanup_compute_lock(self, key: str): |
| 156 | """Clean up compute lock after use to avoid memory leak""" |
| 157 | with self._compute_locks_lock: |
| 158 | if key in self._compute_locks: |
| 159 | # Only delete if no one is using it (not locked) |
| 160 | lock = self._compute_locks[key] |
| 161 | if not lock.locked(): |
| 162 | del self._compute_locks[key] |
| 163 | |
| 164 | def get_or_compute(self, key: str, compute_fn, timeout_seconds: int | None = None) -> Any: |
| 165 | """Get cached value or compute it, preventing concurrent computation |