Context manager for optionally acquiring a lock.
(self, needs_lock: bool)
| 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. |
no outgoing calls
no test coverage detected