Skip to content

Commit

Permalink
Adds dask lock capability for backend writes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pwolfram committed Mar 22, 2016
1 parent 899d1be commit 759db6e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion xarray/backends/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import time
import traceback
import threading
from collections import Mapping

from ..conventions import cf_encoder
Expand Down Expand Up @@ -162,7 +163,11 @@ def add(self, source, target):
def sync(self):
if self.sources:
import dask.array as da
da.store(self.sources, self.targets)
import dask
if dask.__version__ > '0.8.1':
da.store(self.sources, self.targets, lock=threading.Lock())
else:
da.store(self.sources, self.targets)
self.sources = []
self.targets = []

Expand Down

0 comments on commit 759db6e

Please sign in to comment.