Skip to content

Instantly share code, notes, and snippets.

@linw1995
Created April 9, 2021 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linw1995/bb5e9e378e2f3dcb5820fd2dffeead0e to your computer and use it in GitHub Desktop.
Save linw1995/bb5e9e378e2f3dcb5820fd2dffeead0e to your computer and use it in GitHub Desktop.
Click with async command
# Standard Library
import asyncio
import functools
# Third Party Library
import click
def async_command(coro_func):
@functools.wraps(coro_func)
def sync_func(*args, **kwargs):
return asyncio.run(coro_func(*args, **kwargs))
return sync_func
@click.command()
@async_command
async def hello():
print("hello world")
if __name__ == "__main__":
hello()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment