Gets the lock for the provided cache keys, creating one if neccessary.
(self, keys: list[CacheKey])
| 142 | return None |
| 143 | |
| 144 | def get_pred_lock(self, keys: list[CacheKey]) -> threading.RLock: |
| 145 | """Gets the lock for the provided cache keys, creating one if neccessary.""" |
| 146 | # If the lock already exists for the provided keys, return it. |
| 147 | pl_key = self.pred_lock_key(keys) |
| 148 | if pl_key: |
| 149 | return self._pred_locks[pl_key] |
| 150 | # If no such lock exists, create, store and return it. |
| 151 | pred_lock = threading.RLock() |
| 152 | self._pred_locks[self._construct_pred_lock_key(keys)] = pred_lock |
| 153 | return pred_lock |
| 154 | |
| 155 | def delete_pred_lock(self, keys: list[CacheKey]) -> Optional[threading.RLock]: |
| 156 | """Remove the lock from the map to clean up, returns it.""" |