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

Function test_serializable_locks

xarray/tests/test_distributed.py:320–337  ·  view source on GitHub ↗
(c, s, a, b)

Source from the content-addressed store, hash-verified

318
319@gen_cluster(client=True)
320async def test_serializable_locks(c, s, a, b) -> None:
321 def f(x, lock=None):
322 with lock:
323 return x + 1
324
325 # note, the creation of Lock needs to be done inside a cluster
326 for lock in [
327 HDF5_LOCK,
328 Lock(),
329 Lock("filename.nc"),
330 CombinedLock([HDF5_LOCK]),
331 CombinedLock([HDF5_LOCK, Lock("filename.nc")]),
332 ]:
333 futures = c.map(f, list(range(10)), lock=lock)
334 await c.gather(futures)
335
336 lock2 = pickle.loads(pickle.dumps(lock))
337 assert type(lock) is type(lock2)

Callers

nothing calls this directly

Calls 4

CombinedLockClass · 0.90
LockClass · 0.85
typeFunction · 0.85
mapMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…