Skip to content

ResourceWarning: unclosed scandir iterator #311

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
zopyx opened this issue Jul 21, 2019 · 2 comments · Fixed by #475
Closed

ResourceWarning: unclosed scandir iterator #311

zopyx opened this issue Jul 21, 2019 · 2 comments · Fixed by #475
Labels

Comments

@zopyx
Copy link

zopyx commented Jul 21, 2019

Getting this warning under Python 3.7 for scandir():

/home/ajung/.buildout/eggs/fs-2.4.8-py3.7.egg/fs/osfs.py:521: ResourceWarning: unclosed scandir iterator <posix.ScandirIterator object at 0x7f61d00596b0>
yield Info(info)

@willmcgugan
Copy link
Member

Do you have some code to reproduce this?

This will happen if you have an iterator to scandir that isn't full exhausted when it goes out of scope. It's not immediately obvious why it wouldn't close the native scandir iterator at the same time.

@althonos
Copy link
Member

Coming a bit late but I think the issue was caused by the following: since Python 3.6, os.scandir returns a handle that might not free all resources in case it is dropped before exhausted. This can happen in particular when OSFS.scandir is called with a page argument.

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

Successfully merging a pull request may close this issue.

3 participants