Skip to content

Commit 7c571fd

Browse files
committed
test and fix parallel append
1 parent 7afeac5 commit 7c571fd

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

zarr/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ def __repr__(self):
811811

812812
def __getstate__(self):
813813
return self._store, self._path, self._read_only, self._chunk_store, \
814-
self._synchronizer
814+
self._synchronizer, self._cache_metadata
815815

816816
def __setstate__(self, state):
817817
self.__init__(*state)

zarr/tests/test_sync.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,15 @@ def init_attributes(self, store, read_only=False):
4646
read_only=read_only)
4747

4848

49+
def _append_data(arg):
50+
z, i = arg
51+
import numpy as np
52+
x = np.empty(1000, dtype='i4')
53+
x[:] = i
54+
z.append(x)
55+
return z.shape
56+
57+
4958
class MixinArraySyncTests(object):
5059

5160
def test_parallel_append(self):
@@ -55,16 +64,8 @@ def test_parallel_append(self):
5564
arr[:] = 0
5665
pool = self.create_pool(cpu_count())
5766

58-
def f(i):
59-
x = np.empty(1000, dtype='i4')
60-
x[:] = i
61-
arr.append(x)
62-
63-
pool.map_async(f, range(1, 40, 1))
64-
65-
pool.close()
66-
pool.join()
67-
pool.terminate()
67+
results = pool.map_async(_append_data, zip([arr] * 39, range(1, 40, 1)))
68+
print(results.get())
6869

6970
eq((40000,), arr.shape)
7071

0 commit comments

Comments
 (0)