Skip to content

Commit

Permalink
Added closure checks before reading with fsspec
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed Nov 12, 2024
1 parent 7b53ac3 commit 74a0558
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/uproot/source/fsspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 74a0558

Please sign in to comment.