-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fsspec Source (the local file one, at least) does not close files #1292
Comments
I was curious about this, so here's what I found out. The uproot5/src/uproot/source/fsspec.py Lines 193 to 201 in 53f917c
But if you check the underlying file I feel like the comment above is explains the existence of the property, but not why it always returns |
The other issue is that Also, maybe now it makes sense to drop support for Python 3.8 and clean up that method a bit? It would probably make sense to do both for a minor release. |
What we can do is make final releases of Awkward and Uproot with Python 3.8 support, and then immediately afterward make a minor release without Python 3.8 support, so that the change in Awkward version number only changes that level of support. The question then becomes, which PRs do you want to be sure are included in the last with-Python-3.8 release? |
I think it would make sense to at least wait for the fix/perf PRs that are ready (or almost ready). There's no reason to rush to drop Python 3.8, but I did notice that things started to break for 3.8 (see e.g scikit-hep/scikit-hep-testdata#162). |
I saw this in @giedrius2020's talk.
The
with
statement was supposed to close the file, making it impossible to later read the arrays from it. (Without this, thewith
statement is useless: its purpose is to prevent file-handle leaks, and nothing here is closing the file-handle.)This is where the "
file
" object (a ReadOnlyDirectory) has an__exit__
method that gets called at the end of thewith
statement:uproot5/src/uproot/reading.py
Lines 1515 to 1516 in dc19ce9
and here is where that gets propagated to an FSSpecSource:
uproot5/src/uproot/source/fsspec.py
Lines 81 to 83 in dc19ce9
and here's the pre-fsspec Source (MemmapSource):
uproot5/src/uproot/source/file.py
Lines 216 to 223 in dc19ce9
Pre-fsspec file-handles got closed:
Now I wonder why pytest is not complaining about the leaking file-handles. I know that it checks for unclosed files because I've seen that error. Here it is, reproduced on the terminal, and our test suite never raised an error. I don't understand that.
Socially, this could be a problem because the fsspec-based file-handles have been available for almost a year (Uproot 5) and users might have gotten used to opening the file in a
with
statement (uselessly) and later, outside thewith
, initiating more file-reading with TTree, RNTuple, and TDirectory objects. After fixing this, code that relied on this error will break. It will need to be a new minor version number, 5.4.0, at least.The text was updated successfully, but these errors were encountered: