GeezerVison is showing github.com — bpo-38415 @asynccontextmanager as decorators like @contextmanager by fried · Pull Request #16667 · python/cpython
Conversation
fried
commented
Oct 8, 2019
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
I assumed at that an asynccontextmanager would some time be available in the stdlib when we first got async generators. Before it had been released I cooked up an internal version at facebook whiched mapped all the features of @contextmanager but as an async variant. This one feature seems to be missing from the stdlib.
I would like to stop using my version and just use the stdlib version, can we get this feature parity with contextmanager?
@asynccontextmanager
async def our_context(...):
...
yield
...
@our_context(...)
async def some_function(...):
# we are inside the context of our_context now
...
@our_context(...)
async def some_other_function(...):
...
https://bugs.python.org/issue38415
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Awesome! Please create a bpo issue and generate a NEWS file using the blurb tool.
|
fried reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
fried
changed the title
bpo: 38415 @asynccontextmanager as decorators like @contextmanager
bpo:38415 @asynccontextmanager as decorators like @contextmanager
Oct 8, 2019
fried
changed the title
bpo:38415 @asynccontextmanager as decorators like @contextmanager
bpo-38415 @asynccontextmanager as decorators like @contextmanager
Oct 8, 2019
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
@ncoghlan Nick, do you want to take a look at this? Looks good to me.
|
fried reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Rebased on current main (3.11).
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Comment on lines
+194
to
+201
|
|
def __call__(self, func):
|
|
|
@wraps(func)
|
|
|
async def inner(*args, **kwds):
|
|
|
async with self.__class__(self.func, self.args, self.kwds):
|
|
|
return await func(*args, **kwds)
|
|
|
|
|
|
return inner
|
|
|
|
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.
this function is now redundant - support for asynccontextmanagers as decorators was added in #20516
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Reviewers
1st1
1st1 approved these changes
asvetlov
asvetlov approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|