Skip to content

Fixing unclosed file warnings#937

Open
alex-wearisma wants to merge 2 commits intofxsjy:masterfrom
wearisma:fix-unclosed-file-warning
Open

Fixing unclosed file warnings#937
alex-wearisma wants to merge 2 commits intofxsjy:masterfrom
wearisma:fix-unclosed-file-warning

Conversation

@alex-wearisma
Copy link
Copy Markdown

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!

alex-wearisma and others added 2 commits July 25, 2021 15:00
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