xarray.backends.FileManager.acquire_context

FileManager.acquire_context(needs_lock=True)

Context manager for acquiring a file. Yields a file object.

The context manager unwinds any actions taken as part of acquisition (i.e., removes it from any cache) if an exception is raised from the context. It does not automatically close the file.