8000 bpo-38260: Add Docs on asyncio.run by eamanu · Pull Request #16337 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-38260: Add Docs on asyncio.run #16337

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 3 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
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
Next Next commit
Add Docs on asyncio.run
Add docs about return and raise exception on asyncio.run
  • Loading branch information
eamanu committed Sep 23, 2019
commit 39cd32b8ef5f7796b434afead7099402e4fbaa3f
13 changes: 13 additions & 0 deletions Doc/library/asyncio-task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,19 @@ Running an asyncio Program
the end. It should be used as a main entry point for asyncio
programs, and should ideally only be called once.

Return the `base_events.run_until_complete()` that this return the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't need to mention a future and run_until_complete() here.
asyncio.run() returns a result of coro execution, that's it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @asvetlov Thanks for the review. I make the changes

Future's result, or raise a RuntimeError if `asyncio.run()`is called
from a running event loop, or a ValueError if `main` is not a
courutine.

Example::

async def main():
await asyncio.sleep(1)
print('hello')

asyncio.run(main())

.. versionadded:: 3.7

.. versionchanged:: 3.9
Expand Down
5 changes: 5 additions & 0 deletions Lib/asyncio/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ def run(main, *, debug=False):
It should be used as a main entry point for asyncio programs, and should
ideally only be called once.

Return the `base_events.run_until_complete()` that this return the
Future's result, or raise a RuntimeError if `asyncio.run()`is called
from a running event loop, or a ValueError if `main` is not a
courutine.

Example:

async def main():
Expand Down
0