Open
Description
Zarr version
3.0.8
Numcodecs version
0.16.1
Python Version
3.13.0
Operating System
macOS
Installation
uv
Description
I'm trying to modify data concurrently, making sure I'm only modifying one chunk at a time. This doesn't seem to work with multiprocessing though.
Steps to reproduce
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
# ]
# ///
#
# This script automatically imports the development branch of zarr to check for issues
import zarr
from multiprocessing import Pool
def set_to_zero(array, idx):
array[idx] = 0
if __name__ == "__main__":
array = zarr.ones(shape=(2,), chunks=(1,))
print(array[:])
# prints [1, 1]
args = [(array, 0), (array, 1)]
with Pool(1) as pool:
pool.starmap(set_to_zero, args)
print(array[:])
# prints [1, 1]; should print [0, 0]
for arg in args:
set_to_zero(*arg)
print(array[:])
# prints [0, 0]
Additional output
No response