Skip to content
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

gh-127174: add some advice for asyncio.get_event_loop replacements #127640

Merged
merged 9 commits into from
Dec 18, 2024
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: Kumar Aditya <kumaraditya@python.org>
  • Loading branch information
graingert and kumaraditya303 authored Dec 5, 2024
commit 9bb412d56d47f34c98b7be047a36d58c41b72359
8 changes: 4 additions & 4 deletions Doc/whatsnew/3.14.rst
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ asyncio
If you're running an async function, simply use :func:`asyncio.run`,
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved
before::
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved

async def amain():
async def main():
...

loop = asyncio.get_event_loop()
Expand All @@ -788,12 +788,12 @@ asyncio

after::
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved

async def amain():
async def main():
...

asyncio.run(amain())
asyncio.run(main())

If you need to start something, eg, a server listening on a socket
If you need to start something, e.g. a server listening on a socket
and then run forever, use :func:`asyncio.run` and an
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved
:class:`asyncio.Event`, before::
kumaraditya303 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
Loading