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.
(
self, needs_lock: bool = True
)
| 40 | raise NotImplementedError() |
| 41 | |
| 42 | def acquire_context( |
| 43 | self, needs_lock: bool = True |
| 44 | ) -> AbstractContextManager[T_File]: |
| 45 | """Context manager for acquiring a file. Yields a file object. |
| 46 | |
| 47 | The context manager unwinds any actions taken as part of acquisition |
| 48 | (i.e., removes it from any cache) if an exception is raised from the |
| 49 | context. It *does not* automatically close the file. |
| 50 | """ |
| 51 | raise NotImplementedError() |
| 52 | |
| 53 | def close(self, needs_lock: bool = True) -> None: |
| 54 | """Close the file object associated with this manager, if needed.""" |