Skip to content

Commit

Permalink
🩹 Use a context manager when opening a nc dataset (#848)
Browse files Browse the repository at this point in the history
avoid file locking when calling xarray.open_dataset
  • Loading branch information
jsnel authored Oct 3, 2021
1 parent ca1a75e commit 7797bc9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion glotaran/builtin/io/netCDF/netCDF.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
@register_data_io("nc")
class NetCDFDataIo(DataIoInterface):
def load_dataset(self, file_name: str) -> xr.Dataset | xr.DataArray:
return xr.open_dataset(file_name)
with xr.open_dataset(file_name) as ds:
return ds.load()

def save_dataset(
self,
Expand Down

0 comments on commit 7797bc9

Please sign in to comment.