Skip to content

Commit

Permalink
da.store locks by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mrocklin committed Mar 16, 2016
1 parent 57b0203 commit 3d2cc08
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dask/array/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def topk(k, x):
return Array(merge(dsk, x.dask), name2, chunks, dtype=x.dtype)


def store(sources, targets, lock=None, compute=True, **kwargs):
def store(sources, targets, lock=True, compute=True, **kwargs):
""" Store dask arrays in array-like objects, overwrite data in target
This stores dask arrays into object that supports numpy-style setitem
Expand All @@ -677,6 +677,12 @@ def store(sources, targets, lock=None, compute=True, **kwargs):
sources: Array or iterable of Arrays
targets: array-like or iterable of array-likes
These should support setitem syntax ``target[10:20] = ...``
lock: boolean or threading.Lock, optional
Whether or not to lock the data stores while storing.
Pass True (lock each file individually), False (don't lock) or a
particular ``threading.Lock`` object to be shared among all writes.
compute: boolean, optional
If true compute immediately, return lazy Value object otherwise
Examples
--------
Expand Down
5 changes: 5 additions & 0 deletions dask/array/tests/test_array_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,11 @@ def test_store_locks():
v = store([a, b], [at, at], lock=lock,
get=dask.threaded.get, num_workers=10)

# Don't assume thread safety by default
at = NonthreadSafeStore()
store(a, at, get=dask.threaded.get, num_workers=10)
a.store(at, get=dask.threaded.get, num_workers=10)

# Ensure locks can be removed
at = ThreadSafeStore()
for i in range(10):
Expand Down

0 comments on commit 3d2cc08

Please sign in to comment.