Skip to content

Commit 5cca26a

Browse files
committed
Adds dask lock capability for backend writes
This fixes an error on an asynchronous write for `to_netcdf` resulting in an `dask.async.RuntimeError: NetCDF: HDF error` Resolves issue pydata#793 following dask improvement at dask/dask#1053 following advice of @shoyer.
1 parent 899d1be commit 5cca26a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

xarray/backends/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,12 @@ def add(self, source, target):
161161

162162
def sync(self):
163163
if self.sources:
164-
import dask.array as da
165-
da.store(self.sources, self.targets)
164+
import dask, dask.array as da
165+
import threading
166+
if dask.__version__ > '0.8.1':
167+
da.store(self.sources, self.targets, lock=threading.Lock())
168+
else:
169+
da.store(self.sources, self.targets)
166170
self.sources = []
167171
self.targets = []
168172

0 commit comments

Comments
 (0)