mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
gh-92223: Remove pre-Python 3.7 alternative in asyncio docs (#92224)
This commit is contained in:
parent
e61330b44f
commit
d1b2e989be
1 changed files with 1 additions and 16 deletions
|
@ -20,7 +20,7 @@ Coroutines
|
||||||
|
|
||||||
:term:`Coroutines <coroutine>` declared with the async/await syntax is the
|
:term:`Coroutines <coroutine>` declared with the async/await syntax is the
|
||||||
preferred way of writing asyncio applications. For example, the following
|
preferred way of writing asyncio applications. For example, the following
|
||||||
snippet of code (requires Python 3.7+) prints "hello", waits 1 second,
|
snippet of code prints "hello", waits 1 second,
|
||||||
and then prints "world"::
|
and then prints "world"::
|
||||||
|
|
||||||
>>> import asyncio
|
>>> import asyncio
|
||||||
|
@ -223,21 +223,6 @@ Creating Tasks
|
||||||
:exc:`RuntimeError` is raised if there is no running loop in
|
:exc:`RuntimeError` is raised if there is no running loop in
|
||||||
current thread.
|
current thread.
|
||||||
|
|
||||||
This function has been **added in Python 3.7**. Prior to
|
|
||||||
Python 3.7, the low-level :func:`asyncio.ensure_future` function
|
|
||||||
can be used instead::
|
|
||||||
|
|
||||||
async def coro():
|
|
||||||
...
|
|
||||||
|
|
||||||
# In Python 3.7+
|
|
||||||
task = asyncio.create_task(coro())
|
|
||||||
...
|
|
||||||
|
|
||||||
# This works in all Python versions but is less readable
|
|
||||||
task = asyncio.ensure_future(coro())
|
|
||||||
...
|
|
||||||
|
|
||||||
.. important::
|
.. important::
|
||||||
|
|
||||||
Save a reference to the result of this function, to avoid
|
Save a reference to the result of this function, to avoid
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue