8000 bpo-40816 Add AsyncContextDecorator class by heckad · Pull Request #20516 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-40816 Add AsyncContextDecorator class #20516

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 12 commits into from
Nov 5, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix whitespaces
  • Loading branch information
heckad committed Oct 31, 2020
commit 1bace398398b36ddc0be4dc063dcb27e0068e94e
12 changes: 6 additions & 6 deletions Doc/library/contextlib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,16 +128,16 @@ Functions and classes provided:

Context managers defined with :func:`asynccontextmanager` can be used
either as decorators or with :keyword:`async with` statements::

import time
async def timeit():

async def timeit():
now = time.monotonic()
try:
yield
finally:
print(f'it took {time.monotonic() - now}s to run')

@timeit()
async def main():
# ... async code ...
Expand Down Expand Up @@ -377,11 +377,11 @@ Functions and classes provided:


.. class:: AsyncContextManager

Similar as ContextManger only for async

Example of ``ContextDecorator``::

from asyncio import run
from contextlib import AsyncContextDecorator

Expand Down
0