Skip to content

Commit 4d30312

Browse files
committed
add failing multiprocessing test
1 parent 8b77464 commit 4d30312

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_array.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,3 +1382,22 @@ def test_roundtrip_numcodecs() -> None:
13821382
metadata = root["test"].metadata.to_dict()
13831383
expected = (*filters, BYTES_CODEC, *compressors)
13841384
assert metadata["codecs"] == expected
1385+
1386+
1387+
def _index_array(arr: Array, index: Any) -> Any:
1388+
return arr[index]
1389+
1390+
1391+
@pytest.mark.parametrize("store", ["local"], indirect=True)
1392+
def test_multiprocessing(store: Store) -> None:
1393+
"""
1394+
Test that arrays can be pickled and indexed in child processes
1395+
"""
1396+
data = np.arange(100)
1397+
arr = zarr.create_array(store=store, data=data)
1398+
from multiprocessing import Pool
1399+
1400+
pool = Pool()
1401+
1402+
results = pool.starmap(_index_array, [(arr, slice(len(data)))] * 3)
1403+
assert all(np.array_equal(r, data) for r in results)

0 commit comments

Comments
 (0)