Synchronization (zarr.sync)

class zarr.sync.ThreadSynchronizer

Provides synchronization using thread locks.

class zarr.sync.ProcessSynchronizer(path)

Provides synchronization using file locks via the fasteners package.

Parameters:

path : string

Path to a directory on a file system that is shared by all processes.

class zarr.sync.SynchronizedArray(store, synchronizer, readonly=False)

Instantiate a synchronized array.

Parameters:

store : MutableMapping

Array store, already initialised.

synchronizer : object

Array synchronizer.

readonly : bool, optional

True if array should be protected against modification.

Notes

Only writing data to the array via the __setitem__() method and modification of user attributes are synchronized. Neither append() nor resize() are synchronized.

Writing to the array is synchronized at the chunk level. I.e., the array supports concurrent write operations via the __setitem__() method, but these will only exclude each other if they both require modification of the same chunk.

Examples

>>> import zarr
>>> store = dict()
>>> zarr.init_store(store, shape=1000, chunks=100)
>>> synchronizer = zarr.ThreadSynchronizer()
>>> z = zarr.SynchronizedArray(store, synchronizer)
>>> z
zarr.sync.SynchronizedArray((1000,), float64, chunks=(100,), order=C)
  compression: blosc; compression_opts: {'clevel': 5, 'cname': 'blosclz', 'shuffle': 1}
  nbytes: 7.8K; nbytes_stored: 289; ratio: 27.7; initialized: 0/10
  store: builtins.dict; synchronizer: zarr.sync.ThreadSynchronizer