🍾 Xarray is now 10 years old! 🎉

xarray.backends.CachingFileManager.acquire

xarray.backends.CachingFileManager.acquire#

CachingFileManager.acquire(needs_lock=True)[source]#

Acquire a file object from the manager.

A new file is only opened if it has expired from the least-recently-used cache.

This method uses a lock, which ensures that it is thread-safe. You can safely acquire a file in multiple threads at the same time, as long as the underlying file object is thread-safe.

Returns:

file-like – An open file object, as returned by opener(*args, **kwargs).