# xarray.backends.CachingFileManager.acquire

#### CachingFileManager.acquire(needs_lock=True)[[source]](https://github.com/pydata/xarray/blob/main/xarray/backends/file_manager.py#L238-L255)

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](https://docs.python.org/3/glossary.html#term-file-like-object) – An open file object, as returned by `opener(*args, **kwargs)`.
