• Home
  • Raw
  • Download

Lines Matching +full:async +full:- +full:io

8 This section outlines high-level asyncio APIs to work with coroutines
23 ----------------------------------------------------
25 :term:`Coroutines <coroutine>` declared with the async/await syntax is the
32 >>> async def main():
49 * The :func:`asyncio.run` function to run the top-level
59 async def say_after(delay, what):
63 async def main():
86 async def main():
114 async def main():
115 async with asyncio.TaskGroup() as tg:
134 .. _asyncio-awaitables:
154 async def nested():
157 async def main():
173 * a *coroutine function*: an :keyword:`async def` function;
189 async def nested():
192 async def main():
206 A :class:`Future` is a special **low-level** awaitable object that
212 Future objects in asyncio are needed to allow callback-based code
213 to be used with async/await.
221 async def main():
230 A good example of a low-level function that returns a Future object
239 -----------------------------------------------
249 An optional keyword-only *context* argument allows specifying a
265 a task disappearing mid-execution. The event loop only keeps
268 For reliable "fire-and-forget" background tasks, gather them in
301 perform clean-up logic. In case :exc:`asyncio.CancelledError`
303 clean-up is complete. :exc:`asyncio.CancelledError` directly subclasses
325 An :ref:`asynchronous context manager <async-context-managers>`
339 async def main():
340 async with asyncio.TaskGroup() as tg:
345 The ``async with`` statement will wait for all tasks in the group to finish.
349 Once the last task has finished and the ``async with`` block is exited,
356 At this point, if the body of the ``async with`` statement is still active
358 the task directly containing the ``async with`` statement is also cancelled.
360 but it will not bubble out of the containing ``async with`` statement.
373 is re-raised instead of :exc:`ExceptionGroup` or :exc:`BaseExceptionGroup`.
375 If the body of the ``async with`` statement exits with an exception
379 and non-cancellation exceptions are grouped into an
402 tasks to run. This can be used by long-running functions to avoid
413 async def display_date():
434 Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
456 treated as if it raised :exc:`CancelledError` -- the ``gather()``
471 async def factorial(name, number):
480 async def main():
521 or not all positional arguments are Future-like objects
530 Protect an :ref:`awaitable object <asyncio-awaitables>`
566 a task disappearing mid-execution. The event loop only keeps
574 Deprecation warning is emitted if *aw* is not Future-like object
583 An :ref:`asynchronous context manager <async-context-managers>`
597 async def main():
598 async with asyncio.timeout(10):
615 async def main():
617 async with asyncio.timeout(10):
629 An :ref:`asynchronous context manager <async-context-managers>`
635 - If ``when`` is ``None``, the timeout will never trigger.
636 - If ``when < loop.time()``, the timeout will trigger on the next
639 .. method:: when() -> float | None
648 .. method:: expired() -> bool
655 async def main():
658 async with asyncio.timeout(None) as cm:
681 async def main():
685 async with asyncio.timeout_at(deadline):
696 Wait for the *aw* :ref:`awaitable <asyncio-awaitables>`
724 async def eternity():
729 async def main():
780 +-----------------------------+----------------------------------------+
785 +-----------------------------+----------------------------------------+
791 +-----------------------------+----------------------------------------+
794 +-----------------------------+----------------------------------------+
807 Run :ref:`awaitable objects <asyncio-awaitables>` in the *aws*
827 iterable are Future-like objects and there is no running event loop.
845 IO-bound functions/methods that would otherwise block the event loop if
851 # IO-bound operation, such as file operations.
855 async def main():
882 to make IO-bound functions non-blocking. However, for extension modules
884 have one, ``asyncio.to_thread()`` can also be used for CPU-bound functions.
894 Submit a coroutine to the given event loop. Thread-safe.
925 See the :ref:`concurrency and multithreading <asyncio-multithreading>`
972 A :class:`Future-like <Future>` object that runs a Python
973 :ref:`coroutine <coroutine>`. Not thread-safe.
984 IO operations.
986 Use the high-level :func:`asyncio.create_task` function to create
987 Tasks, or the low-level :meth:`loop.create_task` or
1005 An optional keyword-only *context* argument allows specifying a
1036 exception is re-raised.)
1062 This method should only be used in low-level callback-based code.
1071 This method should only be used in low-level callback-based code.
1165 async def cancel_me():
1177 async def main():
1219 used by end-user code. In particular, if a Task gets successfully
1225 async def make_request_with_timeout():
1227 async with asyncio.timeout(1):
1242 If end-user code is, for some reason, suppresing cancellation by
1259 used by end-user code. See :meth:`uncancel` for more details.