MCPcopy Create free account
hub / github.com/PAIR-code/lit / get_pred_lock

Method get_pred_lock

lit_nlp/lib/caching.py:144–153  ·  view source on GitHub ↗

Gets the lock for the provided cache keys, creating one if neccessary.

(self, keys: list[CacheKey])

Source from the content-addressed store, hash-verified

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."""

Callers 5

test_pred_lock_keyMethod · 0.95
test_delete_pred_lockMethod · 0.95
test_get_pred_lockMethod · 0.95
predictMethod · 0.80

Calls 2

pred_lock_keyMethod · 0.95