bpo-33468: Add try-finally contextlib.contextmanager example by Carreau · Pull Request #7816 · python/cpython (original) (raw)
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 andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation17 Commits2 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Contributor
taleinat left a comment • Loading
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change to use an entirely abstract example according to @ncoghlan's suggestion on bpo-33468, or close this PR.
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.
Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again
. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.
I have made the requested changes; please review again
Thanks for making the requested changes!
@taleinat: please review the changes made to this pull request.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, a few minor changes needed IMO.
and doesn't implement a ``close()`` method for use with ``contextlib.closing`` |
---|
A simple example thus would be the following to ensure correct resource |
management:: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the fact that this an abstract example (rather than a concrete one) should be mentioned explicitly.
Also, I suggest removing the word "simple".
foo |
>>> with managed_resource(*args, **kwds) as resource: |
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps avoid *args, **kwds
here? Instead consider e.g. with managed_resource(foo="bar") as resource:
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something more explicit ? timeout=3600
?
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.
Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again
. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.
This increase the chances of people following this example properly cleaning up resources.
I have made the requested changes; please review again
Thanks for making the requested changes!
@taleinat: please review the changes made to this pull request.
Thanks @Carreau for the PR, and @taleinat for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7.
🐍🍒⛏🤖
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
(cherry picked from commit bde782b)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request
(cherry picked from commit bde782b)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com
Thanks @taleinat for the review and the merge !
Sorry, @Carreau and @taleinat, I could not cleanly backport this to 2.7
due to a conflict.
Please backport using cherry_picker on command line.cherry_picker bde782bb594edffeabe978abeee2b7082ab9bc2a 2.7
taleinat pushed a commit to taleinat/cpython that referenced this pull request
(cherry picked from commit bde782b)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com
taleinat pushed a commit that referenced this pull request
(cherry picked from commit bde782b)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com
taleinat pushed a commit that referenced this pull request
(cherry picked from commit bde782b)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com
taleinat added a commit that referenced this pull request
(cherry picked from commit bde782b)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com