Async Click
Asyncclick is a fork of Click that works seamlessly with Trio or asyncio, enabling the use of asynchronous command and subcommand handlers for building composable command line interfaces. It aims to provide the familiar Click API with added async capabilities. The current version is 8.3.0.7, released on October 11, 2025, and generally follows the upstream Click project's release cadence.
Warnings
- breaking `asyncclick.prompt` is now asynchronous and must be awaited. It also introduces a `blocking` parameter.
- breaking `Context.exit` has been renamed to `Context.aexit` and is now an asynchronous method.
- gotcha Do not mix direct imports from the synchronous `click` library and `asyncclick` in the same program.
- gotcha Performing blocking synchronous I/O or CPU-bound operations directly in `async` command handlers will block the event loop, negating the benefits of async programming.
- deprecated Asyncclick inherits deprecations from upstream Click. For example, `BaseCommand` and `MultiCommand` are deprecated in favor of `Command` and `Group` respectively, and the `__version__` attribute is deprecated in favor of `importlib.metadata.version("click")`.
Install
-
pip install asyncclick
Imports
- command
from asyncclick import command
- group
from asyncclick import group
- option
from asyncclick import option
- echo
from asyncclick import echo
- click (alias)
import asyncclick as click
Quickstart
import asyncclick as click
import anyio
@click.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name", help="The person to greet.")
async def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
click.echo(f"Hello, {name}!")
await anyio.sleep(0.1) # Simulate async I/O
if __name__ == '__main__':
# asyncclick automatically starts an anyio event loop
# and runs your code asynchronously.
hello()