-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
bpo-38415 @asynccontextmanager as decorators like @contextmanager #16667
Conversation
Awesome! Please create a bpo issue and generate a |
b6fad49
to
cd79d6c
Compare
alright |
@ncoghlan Nick, do you want to take a look at this? Looks good to me. |
cd79d6c
to
8890d0e
Compare
Rebased on current main (3.11). |
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
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?
https://bugs.python.org/issue38415