-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
bpo-33468: Add try-finally contextlib.contextmanager example #7816
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
Conversation
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.
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 |
Thanks for making the requested changes! @taleinat: please review the changes made to this pull request. |
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.
Looking good, a few minor changes needed IMO.
Doc/library/contextlib.rst
Outdated
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:: |
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.
IMO the fact that this an abstract example (rather than a concrete one) should be mentioned explicitly.
Also, I suggest removing the word "simple".
Doc/library/contextlib.rst
Outdated
<h1> | ||
foo | ||
</h1> | ||
>>> with managed_resource(*args, **kwds) as resource: |
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.
Perhaps avoid *args, **kwds
here? Instead consider e.g. with managed_resource(foo="bar") as resource:
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.
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 |
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. |
…H-7816) (cherry picked from commit bde782b) Co-authored-by: Matthias Bussonnier <[email protected]>
GH-8425 is a backport of this pull request to the 3.7 branch. |
…H-7816) (cherry picked from commit bde782b) Co-authored-by: Matthias Bussonnier <[email protected]>
Thanks @taleinat for the review and the merge ! |
GH-8426 is a backport of this pull request to the 3.6 branch. |
Sorry, @Carreau and @taleinat, I could not cleanly backport this to |
…ythonGH-7816). (cherry picked from commit bde782b) Co-authored-by: Matthias Bussonnier <[email protected]>
GH-8427 is a backport of this pull request to the 2.7 branch. |
GH-8425) (cherry picked from commit bde782b) Co-authored-by: Matthias Bussonnier <[email protected]>
GH-8426) (cherry picked from commit bde782b) Co-authored-by: Matthias Bussonnier <[email protected]>
…H-7816) (GH-8427) (cherry picked from commit bde782b) Co-authored-by: Matthias Bussonnier <[email protected]>
This increase the chances of people following this example properly
cleaning up resources.
https://bugs.python.org/issue33468