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

Fixing unclosed file warnings #937

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alex-wearisma
Copy link

Hello,

There are some open() calls which are not closed after the use. Leaving file handles open leaks resources and makes Python raise warning such as the one bellow:

/Users/coder/project/extract.py:72: ResourceWarning: unclosed file <_io.BufferedReader name='/Users/coder/project/resources/keywords/zh/userdict.txt'>
  jieba.load_userdict(str(p))
ResourceWarning: Enable tracemalloc to get the object allocation traceback

This change closes all open file handles.

This change should also solve issue reported here: #546 .

Thank you!

Closing all open file handlers to avoid unclosed file warnings.
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

Successfully merging this pull request may close these issues.

1 participant