Skip to content

Commit

Permalink
Make a rather long race condition much shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Mar 22, 2024
1 parent a502745 commit 9c28182
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion xarray_ecmwf/engine_ecmwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ def cached_empty_dataset(self, request: dict[str, Any]) -> Iterator[xr.Dataset]:

if not os.path.exists(path):
with self.retrieve(request, override_cache_file=True) as read_ds:
read_ds.to_zarr(path, compute=False)
# check again as the retrieve may be long
if not os.path.exists(path):
read_ds.to_zarr(path, compute=False)
yield xr.open_dataset(path, engine="zarr")


Expand Down

0 comments on commit 9c28182

Please sign in to comment.