MCPcopy Index your code
hub / github.com/pydata/xarray / CombinedLock

Class CombinedLock

xarray/backends/locks.py:210–239  ·  view source on GitHub ↗

A combination of multiple locks. Like a locked door, a CombinedLock is locked if any of its constituent locks are locked.

Source from the content-addressed store, hash-verified

208
209
210class CombinedLock(Lock):
211 """A combination of multiple locks.
212
213 Like a locked door, a CombinedLock is locked if any of its constituent
214 locks are locked.
215 """
216
217 def __init__(self, locks: Sequence[Lock]):
218 self.locks = tuple(set(locks)) # remove duplicates
219
220 def acquire(self, blocking=True):
221 return all(acquire(lock, blocking=blocking) for lock in self.locks)
222
223 def release(self):
224 for lock in self.locks:
225 lock.release()
226
227 def __enter__(self):
228 for lock in self.locks:
229 lock.__enter__()
230
231 def __exit__(self, *args):
232 for lock in self.locks:
233 lock.__exit__(*args)
234
235 def locked(self):
236 return any(lock.locked() for lock in self.locks)
237
238 def __repr__(self):
239 return f"CombinedLock({list(self.locks)!r})"
240
241
242class DummyLock(Lock):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…