-
Notifications
You must be signed in to change notification settings - Fork 278
Close file objects, requests.Responses #1147
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
Close file objects, requests.Responses #1147
Conversation
These are good changes I think, but I guess there's also a case to be made for silencing ResourceWarnings about these things in the testsuite:
I'm not in favor of silencing: just mentioning it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great changes!
I tried them locally and I don't see Resource warnings
when running tests_download.py
and tests_updater.py
.
Can you increase the scope of this pr and fix the other instances in the other tests files Resource warnings
(as mentioned in #1123) or that will be much of work right now?
This is the scope for now I think. Finding/fixing the trickier ones can take quite a bit of time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for these changes, it's nice to see the number of warnings produced by the tests being reduced.
* move code to only create objects after potential raises * Use 'with' when possible * close manually if those did not help Signed-off-by: Jussi Kukkonen <[email protected]>
Use 'with' to avoid leaking responses when response.raise_for_status() is used. Signed-off-by: Jussi Kukkonen <[email protected]>
* Remove dead urls: trust reader to find Requests documentation on their own * Mention that "stream" means that downloading the body is deferred Signed-off-by: Jussi Kukkonen <[email protected]>
d79d3d9
to
fb9d8e7
Compare
The last change only updated the code comment in the first commit based on Joshuas comment. No other changes. |
Fixes issue #1099:
maybe also #1123 (but I've only gone through the code exercised by test_updater.py and test_download.py)
Description of the changes being introduced by the pull request:
Try to close all file objects and requests.Responses that are left open during test_updater.py and test_download.py execution.
Please verify and check that the pull request fulfills the following
requirements: