Skip to content

ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'> #4355

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

Closed
blueyed opened this issue Nov 9, 2018 · 6 comments
Labels
plugin: warnings related to the warnings builtin plugin type: infrastructure improvement to development/releases/CI structure

Comments

@blueyed
Copy link
Contributor

blueyed commented Nov 9, 2018

I've seen the following on full run of the test suite:

============== 1 failed, 2270 passed, 83 skipped, 13 xfailed in 271.31 seconds ==============
Exception ignored in: <_io.FileIO name='/dev/null' mode='rb' closefd=True>
ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>
Exception ignored in: <_io.FileIO name=13 mode='rb+' closefd=True>
ResourceWarning: unclosed file <_io.FileIO name=13 mode='rb+' closefd=True>
Exception ignored in: <_io.FileIO name=15 mode='rb+' closefd=True>
ResourceWarning: unclosed file <_io.FileIO name=15 mode='rb+' closefd=True>
Exception ignored in: <_io.FileIO name='/dev/null' mode='rb' closefd=True>
ResourceWarning: unclosed file <_io.TextIOWrapper name='/dev/null' mode='r' encoding='UTF-8'>
Exception ignored in: <_io.FileIO name=19 mode='rb+' closefd=True>
ResourceWarning: unclosed file <_io.FileIO name=19 mode='rb+' closefd=True>
Exception ignored in: <_io.FileIO name=21 mode='rb+' closefd=True>
ResourceWarning: unclosed file <_io.FileIO name=21 mode='rb+' closefd=True>

Related to #3879 in that it would be nice if those would cause CI to fail.

I have not investigated what triggered them.
This was on 8baeb90.

@blueyed blueyed added type: infrastructure improvement to development/releases/CI structure plugin: warnings related to the warnings builtin plugin labels Nov 9, 2018
@asottile
Copy link
Member

asottile commented Nov 9, 2018

It's going to be hard to turn these into failures -- these are exceptions triggered as the interpreter is shutting down. I think the best we can do is fix them and hope they don't come back.

From what I can tell, the only opening of devnull in the project is in FDCaptureBinary. I suspect ~something is making module-level references to an instance of these (which gets cleaned up at interpreter shutdown).

@RonnyPfannschmidt
Copy link
Member

lets just do a gc.collect in session shutdown to see more information, perhaps even after each test (perhaps as part of the lsoff plugin)

@asottile
Copy link
Member

asottile commented Nov 9, 2018

A gc.collect isn't necessarily going to catch this. It's likely module globals holding onto these :/

@blueyed
Copy link
Contributor Author

blueyed commented Nov 9, 2018

Is it maybe coming from inner pytest runs?
Or would those show up with the particular tests then only?

@asottile
Copy link
Member

asottile commented Nov 9, 2018

mayyybe, but probably much less likely (unless they're complex second or third generation gc objects and the tests that leak them happen to be at the end). I've really only seen the "Exception ignored ..." errors during module teardown though 🤷‍♂️

blueyed added a commit to blueyed/pytest that referenced this issue Mar 27, 2019
Also done in test_pluginmanager, although no resource warnings are
there at least.

Fixes pytest-dev#4355.
blueyed added a commit to blueyed/pytest that referenced this issue Mar 27, 2019
Also done in test_pluginmanager, although no resource warnings are
there at least.

Fixes pytest-dev#4355.
@blueyed
Copy link
Contributor Author

blueyed commented Mar 27, 2019

=> #5006

blueyed added a commit to blueyed/pytest that referenced this issue Mar 27, 2019
Also done in test_pluginmanager, although no resource warnings are
there at least.

Fixes pytest-dev#4355.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: warnings related to the warnings builtin plugin type: infrastructure improvement to development/releases/CI structure
Projects
None yet
Development

No branches or pull requests

3 participants