asyncio (PyPI backport)

4.0.0 · deprecated · verified Sun Mar 29

The `asyncio` package on PyPI (version 4.0.0) is a deprecated backport of the `asyncio` module, which has been part of Python's standard library since Python 3.4. This PyPI distribution is no longer needed and serves primarily to prevent accidental installation of outdated backports. Users should *not* install this package and instead rely on the built-in `asyncio` module provided by their Python installation.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates basic usage of the standard library `asyncio` module, showing how to define asynchronous functions (coroutines) with `async def`, pause execution with `await asyncio.sleep()`, and run the top-level coroutine using `asyncio.run()`.

import asyncio
import time

async def say_after(delay, what):
    await asyncio.sleep(delay)
    print(what)

async def main():
    print(f"started at {time.strftime('%X')}")

    await say_after(1, 'hello')
    await say_after(2, 'world')

    print(f"finished at {time.strftime('%X')}")

if __name__ == "__main__":
    # The recommended way to run the top-level async function.
    asyncio.run(main())

view raw JSON →