Skip to content

Commit

Permalink
[Docs] Add instruction for "to_async" api
Browse files Browse the repository at this point in the history
  • Loading branch information
aicorein committed Oct 25, 2024
1 parent d6375a8 commit 1ed9c75
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/source/intro/async-callable.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,18 @@ await bar1()
await bar2()
await bar3()
```

在 melobot 中,也提供了装饰器 {func}`.to_async` 转换可调用为异步可调用:

```python
# 在一般函数上装饰,转换为异步可调用
@to_async
def sync_func(...):
...

# 直接调用,适用于各种可调用对象:
async def _any_coro_f(*args, **kwargs): ...
f = to_async(lambda: _any_coro_f(1, 2, 3))

aprint = to_async(print)
```

0 comments on commit 1ed9c75

Please sign in to comment.