Issue 13222: Erroneous unclosed file warning (original) (raw)
Issue13222
This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/57431
classification
Title: | Erroneous unclosed file warning | |
---|---|---|
Type: | Stage: | |
Components: | Versions: | Python 3.2, Python 3.3 |
process
Status: | closed | Resolution: | not a bug |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | Nosy List: | giampaolo.rodola, pitrou | |
Priority: | normal | Keywords: |
Created on 2011-10-19 18:53 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg145936 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * ![]() |
Date: 2011-10-19 18:53 |
/opt/python3.2/lib/python3.2/site-packages/psutil/_pslinux.py:389: ResourceWarning: unclosed file <_io.FileIO name=7 mode='rb'> return [x for x in f.read().split('\x00') if x] I get this while running tests. The method in question is defined as such: @wrap_exceptions def get_process_cmdline(self): f = open("/proc/%s/cmdline" % self.pid) try: # return the args as a list return [x for x in f.read().split('\x00') if x] finally: f.close() ...therefore, I'm closing the file object (in the finally block). | ||
msg145938 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2011-10-19 19:06 |
Since the "name" is 7, it's certainly another file than the one opened in: f = open("/proc/%s/cmdline" % self.pid) It could be that you called open on the result of os.pipe(), or perhaps you used a subprocess and didn't call communicate() or close() on it. | ||
msg145992 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * ![]() |
Date: 2011-10-19 23:31 |
Indeed you were right. Thanks. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:57:22 | admin | set | github: 57431 |
2011-10-19 23:31:52 | giampaolo.rodola | set | messages: + |
2011-10-19 19:06:38 | pitrou | set | status: open -> closedresolution: not a bugmessages: + |
2011-10-19 18:53:48 | giampaolo.rodola | create |