-
Notifications
You must be signed in to change notification settings - Fork 89
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
Lazy open output files, and always close them #314
Lazy open output files, and always close them #314
Conversation
fee8ae3
to
94a0007
Compare
Rebased on |
94a0007
to
11c7a5d
Compare
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.
One question inline, but otherwise looks fine.
I'm curious about the impact of leaving open files in a CLI tool - don't those descriptors disappear once the runtime exits?
Considering the primary use cases for this project is a library, how important is this change?
Great questions.
|
11c7a5d
to
0f58147
Compare
Thanks for the context, and that makes sense. The library was never fully intended as a CLI, so please be mindful of the
This makes most sense here.
Yes please! If we have a specific reason to move it to the "outer" behavior you've described, then we can do that at a later time, but we should use the built-in if possible. |
a6a2aaf
to
f14d946
Compare
Oh no, my commit signatures appear to have been broken by using GitHub's web UI to rebase on Regarding the |
The warnings are only displayed. They are not escalated to errors.
f14d946
to
3c42ccf
Compare
Thanks! Merging now. If you'd like to craft a CHANGES.rst entry for 44.0, we can get these released. Here's an example of a previous PR for releases: #303 |
This PR modifies the test suite to show all warnings, including
ResourceWarning
. By doing so, this revealed that the CLI code never closes output files opened byargparse
during argument parsing.Therefore, this PR additionally modifies the CLI code to open output files only when they will be written to, and ensures that they are always closed after writing.