Skip to content

Commit b600259

Browse files
committed
try without tempdir
1 parent 63b3b6b commit b600259

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

zarr/tests/test_sync.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import atexit
55
import json
66
import shutil
7+
import os
78
from multiprocessing.pool import ThreadPool, Pool as ProcessPool
89
from multiprocessing import cpu_count
910
import tempfile
@@ -26,17 +27,6 @@
2627
from zarr.hierarchy import Group
2728

2829

29-
if PY2:
30-
31-
class TemporaryDirectory(object):
32-
def __init__(self):
33-
self.name = tempfile.mkdtemp()
34-
atexit.register(atexit_rmtree, self.name)
35-
36-
else:
37-
from tempfile import TemporaryDirectory
38-
39-
4030
class TestAttributesWithThreadSynchronizer(TestAttributes):
4131

4232
def init_attributes(self, store, read_only=False):
@@ -79,7 +69,7 @@ def _set_arange(arg):
7969
class MixinArraySyncTests(object):
8070

8171
def test_parallel_setitem(self):
82-
n = 200
72+
n = 20
8373

8474
# setup
8575
arr = self.create_array(shape=n * 1000, chunks=999, dtype='i4')
@@ -94,7 +84,7 @@ def test_parallel_setitem(self):
9484
assert_array_equal(np.arange(n * 1000), arr[:])
9585

9686
def test_parallel_append(self):
97-
n = 200
87+
n = 20
9888

9989
# setup
10090
arr = self.create_array(shape=1000, chunks=999, dtype='i4')
@@ -140,9 +130,12 @@ def create_pool(self):
140130
class TestArrayWithProcessSynchronizer(TestArray, MixinArraySyncTests):
141131

142132
def create_array(self, read_only=False, **kwargs):
143-
store = DirectoryStore(TemporaryDirectory().name)
133+
path = 'test_sync'
134+
if os.path.exists(path):
135+
shutil.rmtree(path)
136+
store = DirectoryStore(path)
144137
init_array(store, **kwargs)
145-
synchronizer = ProcessSynchronizer(TemporaryDirectory().name)
138+
synchronizer = ProcessSynchronizer('test_sync_locks')
146139
return Array(store, synchronizer=synchronizer,
147140
read_only=read_only, cache_metadata=False)
148141

@@ -242,15 +235,18 @@ def test_synchronizer_property(self):
242235
class TestGroupWithProcessSynchronizer(TestGroup, MixinGroupSyncTests):
243236

244237
def create_store(self):
245-
return DirectoryStore(TemporaryDirectory().name), None
238+
path = 'test_sync'
239+
if os.path.exists(path):
240+
shutil.rmtree(path)
241+
store = DirectoryStore(path)
242+
return store, None
246243

247244
def create_group(self, store=None, path=None, read_only=False,
248245
chunk_store=None, synchronizer=None):
249246
if store is None:
250-
store = DirectoryStore(TemporaryDirectory().name)
251-
chunk_store = None
247+
store, chunk_store = self.create_store()
252248
init_group(store, path=path, chunk_store=chunk_store)
253-
synchronizer = ProcessSynchronizer(TemporaryDirectory().name)
249+
synchronizer = ProcessSynchronizer('test_sync_locks')
254250
g = Group(store, path=path, read_only=read_only,
255251
synchronizer=synchronizer, chunk_store=chunk_store)
256252
return g

0 commit comments

Comments
 (0)