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

blob.py: ResourceWarning unclosed file #270

Open
zopyx opened this issue May 18, 2019 · 6 comments
Open

blob.py: ResourceWarning unclosed file #270

zopyx opened this issue May 18, 2019 · 6 comments
Labels

Comments

@zopyx
Copy link
Member

zopyx commented May 18, 2019

Plone 5.2, Python 3.6.

We perform a migration import over plone.restapi.

Each uploaded file results in warning on the console

/home/ajung/sandboxes/ugent-portaal-plone-4x/eggs/ZODB-5.5.1-py3.6.egg/ZODB/blob.py:339: ResourceWarning: unclosed file <_io.FileIO name='/tmp/BUCe14dcpak' mode='rb' closefd=True>
super(BlobFile, self).close()

@zopyx zopyx added the bug label May 18, 2019
@d-maurer
Copy link
Contributor

d-maurer commented May 18, 2019 via email

@zopyx
Copy link
Member Author

zopyx commented Jun 4, 2022

The issue is still pending (any annoying)...I still see the error in Plone 6.0.0a4:

/Users/ajung/src/plone6.buildout/eggs/ZODB-5.7.0-py3.9.egg/ZODB/blob.py:338: ResourceWarning: unclosed file <_io.FileIO name='/Users/ajung/src/plone6.buildout/var/blobstorage/0x00/0x00/0x00/0x00/0x01/0x88/0xa1/0xa6/0x03e8a997b8fa1233.blob' mode='rb' closefd=True>

@d-maurer
Copy link
Contributor

d-maurer commented Jun 4, 2022

The issue is still pending (any annoying)...I still see the error in Plone 6.0.0a4:

/Users/ajung/src/plone6.buildout/eggs/ZODB-5.7.0-py3.9.egg/ZODB/blob.py:338: ResourceWarning: unclosed file <_io.FileIO name='/Users/ajung/src/plone6.buildout/var/blobstorage/0x00/0x00/0x00/0x00/0x01/0x88/0xa1/0xa6/0x03e8a997b8fa1233.blob' mode='rb' closefd=True>

Potentially, this is not a ZODB problem: I have recently hunted down ResourceWarnings in the context of ZEO. Many ZEO tests involve blobs and none of them has raised a blob related ResourceWarning.

I assume that application code forgets to call close on a BlobFile.

@zopyx
Copy link
Member Author

zopyx commented Jun 4, 2022

At least in my case, there is no add-on code involved that would deal with blobs directly.

@dataflake
Copy link
Member

In your situation I would manually add debugging code to see where in the code the warning is originating and what that blob item is. That may help.

@d-maurer
Copy link
Contributor

d-maurer commented Jun 4, 2022

It is quite easy to determine the context which has created an improperly finalized resource:
export PYTHONTRACEMALLOC=frcount; then rerun. This remembers frame information for up to frcount frames with each allocated object; a RessourceWarning will include the remembered information for the respective resource.

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

No branches or pull requests

3 participants