Skip to content

Commit 86bf869

Browse files
committed
Added closure checks before reading with fsspec
1 parent 9b942a0 commit 86bf869

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/uproot/source/fsspec.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ def chunk(self, start: int, stop: int) -> uproot.source.chunk.Chunk:
9292
Request a byte range of data from the file as a
9393
:doc:`uproot.source.chunk.Chunk`.
9494
"""
95+
if self.closed:
96+
raise OSError(f"memmap is closed for file {self._file_path}")
97+
9598
self._num_requests += 1
9699
self._num_requested_chunks += 1
97100
self._num_requested_bytes += stop - start
@@ -129,6 +132,9 @@ def chunks(
129132
it is triggered by already-filled chunks, rather than waiting for
130133
chunks to be filled.
131134
"""
135+
if self.closed:
136+
raise OSError(f"memmap is closed for file {self._file_path}")
137+
132138
self._num_requests += 1
133139
self._num_requested_chunks += len(ranges)
134140
self._num_requested_bytes += sum(stop - start for start, stop in ranges)

0 commit comments

Comments
 (0)