diff options
author | Andrew Svetlov <andrew.svetlov@gmail.com> | 2022-03-24 19:51:16 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-24 19:51:16 (GMT) |
commit | 4119d2d7c9e25acd4f16994fb92d656f8b7816d7 (patch) | |
tree | 13f5086fc5ad0247381d347c4271a8ca79a20fd7 /Doc/library/asyncio-task.rst | |
parent | 2f49b97cc5426087b46515254b9a97a22ee8c807 (diff) | |
download | cpython-4119d2d7c9e25acd4f16994fb92d656f8b7816d7.zip cpython-4119d2d7c9e25acd4f16994fb92d656f8b7816d7.tar.gz cpython-4119d2d7c9e25acd4f16994fb92d656f8b7816d7.tar.bz2 |
bpo-47062: Implement asyncio.Runner context manager (GH-31799)
Co-authored-by: Zachary Ware <zach@python.org>
Diffstat (limited to 'Doc/library/asyncio-task.rst')
-rw-r--r-- | Doc/library/asyncio-task.rst | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/Doc/library/asyncio-task.rst b/Doc/library/asyncio-task.rst index 21a4cb582..c104ac5 100644 --- a/Doc/library/asyncio-task.rst +++ b/Doc/library/asyncio-task.rst @@ -204,43 +204,6 @@ A good example of a low-level function that returns a Future object is :meth:`loop.run_in_executor`. -Running an asyncio Program -========================== - -.. function:: run(coro, *, debug=False) - - Execute the :term:`coroutine` *coro* and return the result. - - This function runs the passed coroutine, taking care of - managing the asyncio event loop, *finalizing asynchronous - generators*, and closing the threadpool. - - This function cannot be called when another asyncio event loop is - running in the same thread. - - If *debug* is ``True``, the event loop will be run in debug mode. - - This function always creates a new event loop and closes it at - the end. It should be used as a main entry point for asyncio - programs, and should ideally only be called once. - - Example:: - - async def main(): - await asyncio.sleep(1) - print('hello') - - asyncio.run(main()) - - .. versionadded:: 3.7 - - .. versionchanged:: 3.9 - Updated to use :meth:`loop.shutdown_default_executor`. - - .. note:: - The source code for ``asyncio.run()`` can be found in - :source:`Lib/asyncio/runners.py`. - Creating Tasks ============== |