-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BLD/IO: Elusive Travis ResourceWarning & closing files by default #22675
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
Comments
I started to look into this yesterday, and will try again today. If anyone is able to reproduce locally, let me know. The interesting part is that the errors always reference zip files like |
Kept having lots of those as well, and commented about it in the closest-seeming issue I found (#13962 (comment)), including some links to failed builds (July 2018). |
Is it the warning that's coming from the unrelated test or just the unclosed file? |
I was able to reproduce locally with
It seems like the unclosed file warning has to be from a separate test right? In e.g. https://travis-ci.org/pandas-dev/pandas/jobs/427395352#L2258 we shouldn't be opening / closing a zip file. |
Yah, I'm just trying to rule out the extra-weird case where the ResourceWarning is being issued during the compression test but only showing up in the parser test, as opposed to the less-weird case where the compression test leaves a file open but that file only leads to a ResourceWarning later on. Could check |
Gotcha, I suspect (hope) that the less-weird case is what's happening. |
Hmm, this looks fishy: https://github.com/pandas-dev/pandas/blob/master/pandas/tests/io/test_pickle.py#L345-L348 We're creating a zipfile and not closing that. Let's give that a shot. |
This is seemingly not fixed by #22679.
|
Interesting, this error appears on a different test. Does Lines 195 to 209 in 71852da
|
Hmm, that may be it. Let me play with that. |
No luck on that I think. Closing the archive doesn't seem to have any effect if the file is closed.
|
Regardless, #22699 should make this trivial to debug. The warning should fail the test it's actually popping up in. |
Logging another case of this: https://travis-ci.org/pandas-dev/pandas/jobs/428987214
edit: and again... (edit2: seems a maintainer restarted this build just as I triggered another run, so now the log is gone)
edit3: https://travis-ci.org/pandas-dev/pandas/jobs/429023439 |
Closed by #22699 I believe. |
Every once in a while Travis will raise a
ResourceWarning
And currently our file closing mechanism for parser functions is like so:
pandas/pandas/io/parsers.py
Lines 459 to 463 in 73dd6ec
It seems pointless having a generic
try
/except
within anif
statement (why have the if statement at all then?). More broadly, should we attempt to close all file-like objects anyways even if they are not necessarily needed (like StringIO in this Travis case)? Might help alleviate this Travis error.Some examples:
The text was updated successfully, but these errors were encountered: