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

Method _optional_lock

xarray/backends/file_manager.py:178–184  ·  view source on GitHub ↗

Context manager for optionally acquiring a lock.

(self, needs_lock: bool)

Source from the content-addressed store, hash-verified

176
177 @contextmanager
178 def _optional_lock(self, needs_lock: bool):
179 """Context manager for optionally acquiring a lock."""
180 if needs_lock:
181 with self._lock:
182 yield
183 else:
184 yield
185
186 def acquire(self, needs_lock: bool = True) -> T_File:
187 """Acquire a file object from the manager.

Callers 2

closeMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected