docs: Improve Container.pull docs to avoid leaky files#2508
Conversation
Co-authored-by: Tony Meyer <tony.meyer@gmail.com>
|
@dwilding and @james-garner-canonical: in the issue, James suggested using |
There was a problem hiding this comment.
The changes to the docstrings and the custom notices example are a nice fix, thanks!
The changes to the managing files in the workload container guide clash with #2470. I'd suggest dropping the changes to the file made in this PR, and adding any that are relevant to #2470 (though I'm not sure if any of them are since we're switching to pathops for most examples -- but maybe worth mentioning the file closing issue doesn't affect pathops?).
Other suggestions are all non-blocking.
Ah yes, the PR I keep forgetting that I have only half-reviewed. Fixed now! Thanks for calling that out. |
Co-authored-by: Tony Meyer <tony.meyer@gmail.com>
Co-authored-by: James Garner <james.garner@canonical.com>
Container.pull(and theClient.pullit wraps) return an opened file that is never explicitly closed. This leaks a resource until garbage collection (which then emits a warning), and in the case ofencoding=Nonecan leak that resource until process end. This is not a significant problem, but we should document the clean, rather than leaky, way to use these methods.The how-to guide has poor suggestions as well, but those are all being replaced in #2470 (to use pathops) so are not worth fixing here.
Fixes #2504