Skip to content

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

Merged
merged 2 commits into from
Jul 23, 2018

Conversation

Carreau
Copy link
Contributor

@Carreau Carreau commented Jun 20, 2018

This increase the chances of people following this example properly
cleaning up resources.

https://bugs.python.org/issue33468

Copy link
Contributor

@taleinat taleinat left a comment

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.

@bedevere-bot
Copy link

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.

@Carreau
Copy link
Contributor Author

Carreau commented Jul 23, 2018

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@taleinat: please review the changes made to this pull request.

Copy link
Contributor

@taleinat taleinat left a 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.

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::
Copy link
Contributor

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".

<h1>
foo
</h1>
>>> with managed_resource(*args, **kwds) as resource:
Copy link
Contributor

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:

Copy link
Contributor Author

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 ?

@bedevere-bot
Copy link

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.
@Carreau
Copy link
Contributor Author

Carreau commented Jul 23, 2018

I have made the requested changes; please review again

@bedevere-bot
Copy link

Thanks for making the requested changes!

@taleinat: please review the changes made to this pull request.

@taleinat taleinat merged commit bde782b into python:master Jul 23, 2018
@miss-islington
Copy link
Contributor

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 Jul 23, 2018
@bedevere-bot
Copy link

GH-8425 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 23, 2018
@Carreau
Copy link
Contributor Author

Carreau commented Jul 23, 2018

Thanks @taleinat for the review and the merge !

@bedevere-bot
Copy link

GH-8426 is a backport of this pull request to the 3.6 branch.

@miss-islington
Copy link
Contributor

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 Jul 23, 2018
@bedevere-bot
Copy link

GH-8427 is a backport of this pull request to the 2.7 branch.

taleinat pushed a commit that referenced this pull request Jul 23, 2018
taleinat pushed a commit that referenced this pull request Jul 23, 2018
taleinat added a commit that referenced this pull request Jul 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants