Skip to content
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

Resource warning due to unclosed IO stream #11

Open
giampaolo opened this issue Apr 25, 2020 · 0 comments
Open

Resource warning due to unclosed IO stream #11

giampaolo opened this issue Apr 25, 2020 · 0 comments

Comments

@giampaolo
Copy link

Hello and thanks for this useful tool. I am trying to integrate it into psutil here: giampaolo/psutil#1709. After running the parallel suite I get a bunch of resource warnings (as many as the number of workers):

/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=11>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=10>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=9>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=7>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=6>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=5>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=12>
  return self.run(*args, **kwds)
/home/giampaolo/.local/lib/python3.6/site-packages/unittest2/suite.py:87: ResourceWarning: unclosed file <_io.BufferedReader name=8>
  return self.run(*args, **kwds)

I was able to fix the problem by adding atexit.register(stream.close) after this line but am not sure if it's the best solution:

stream = os.fdopen(c2pread, 'rb', 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant