Skip to content

Commit

Permalink
fix: fsspec closure checks (#1333)
Browse files Browse the repository at this point in the history
* Fix closed property

* Added closure checks before reading with fsspec

* Fixed error messages
  • Loading branch information
ariostas authored Nov 12, 2024
1 parent 9420c52 commit 9568d90
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 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"file {self._file_path!r} is closed")

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"file {self._file_path!r} is closed")

self._num_requests += 1
self._num_requested_chunks += len(ranges)
self._num_requested_bytes += sum(stop - start for start, stop in ranges)
Expand Down Expand Up @@ -184,7 +190,7 @@ def closed(self) -> bool:
True if the associated file/connection/thread pool is closed; False
otherwise.
"""
return False
return self._file.closed


class FSSpecLoopExecutor(uproot.source.futures.Executor):
Expand Down

0 comments on commit 9568d90

Please sign in to comment.