From 86bf869bbdfcb96cbbeb902ffe75d5a604c66e3c Mon Sep 17 00:00:00 2001 From: Andres Rios Tascon Date: Thu, 7 Nov 2024 14:32:37 -0500 Subject: [PATCH] Added closure checks before reading with fsspec --- src/uproot/source/fsspec.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/uproot/source/fsspec.py b/src/uproot/source/fsspec.py index 75a0af1ba..5c817ccc7 100644 --- a/src/uproot/source/fsspec.py +++ b/src/uproot/source/fsspec.py @@ -92,6 +92,9 @@ def chunk(self, start: int, stop: int) -> uproot.source.chunk.Chunk: Request a byte range of data from the file as a :doc:`uproot.source.chunk.Chunk`. """ + if self.closed: + raise OSError(f"memmap is closed for file {self._file_path}") + self._num_requests += 1 self._num_requested_chunks += 1 self._num_requested_bytes += stop - start @@ -129,6 +132,9 @@ def chunks( it is triggered by already-filled chunks, rather than waiting for chunks to be filled. """ + if self.closed: + raise OSError(f"memmap is closed for file {self._file_path}") + self._num_requests += 1 self._num_requested_chunks += len(ranges) self._num_requested_bytes += sum(stop - start for start, stop in ranges)