MCPcopy Index your code
hub / github.com/pydata/xarray / close

Method close

xarray/backends/file_manager.py:234–242  ·  view source on GitHub ↗

Explicitly close any associated file object (if necessary).

(self, needs_lock: bool = True)

Source from the content-addressed store, hash-verified

232 return file, True
233
234 def close(self, needs_lock: bool = True) -> None:
235 """Explicitly close any associated file object (if necessary)."""
236 # TODO: remove needs_lock if/when we have a reentrant lock in
237 # dask.distributed: https://github.com/dask/dask/issues/3832
238 with self._optional_lock(needs_lock):
239 default = None
240 file = self._cache.pop(self._key, default)
241 if file is not None:
242 file.close()
243
244 def __del__(self) -> None:
245 # If we're the only CachingFileManger referencing an unclosed file,

Calls 2

_optional_lockMethod · 0.95
closeMethod · 0.45