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

Resource Warning by uploading file #24

Open
KoppDaniel opened this issue Jun 30, 2020 · 2 comments
Open

Resource Warning by uploading file #24

KoppDaniel opened this issue Jun 30, 2020 · 2 comments

Comments

@KoppDaniel
Copy link

By using the keyword 'Upload File' i get the following warning message:

C:\Program Files\Python 3.7\lib\site-packages\FtpLibrary.py:409: ResourceWarning: unclosed file <io.BufferedReader name='C:\Path\To\My\File'>
outputMsg += thisConn.storbinary("STOR " + remoteFileName
, open(localFilePath, "rb"))
ResourceWarning: Enable tracemalloc to get the object allocation traceback

@kowalpy
Copy link
Owner

kowalpy commented Jul 3, 2020

@KoppDaniel please upload log files if possible

@KoppDaniel
Copy link
Author

KoppDaniel commented Mar 15, 2021

@kowalpy Sorry I was not able to upload any log file.

But the issue is on lune 409 of FtpLibrary.py that a file is give to the function storbinary but it is never closed.

outputMsg += thisConn.storbinary("STOR " + remoteFileName_, open(localFilePath, "rb"))

The fix would be the following:

with open(localFilePath, 'rb') as localFile:
outputMsg += thisConn.storbinary("STOR " + remoteFileName_, localFile)

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

No branches or pull requests

2 participants