# utils/decorators.py from typing importCallable, TypeVar from typing_extensions import ParamSpec from collections.abc importCoroutine from functools import partial import asyncio
P = ParamSpec("P") R = TypeVar("R")
defrun_sync(call: Callable[P, R]) -> Callable[P, Coroutine[None, None, R]]: """一个用于包装 sync function 为 async function 的装饰器 参数: call: 被装饰的同步函数 """
hello 0 hello 1 hello 2 hello 3 hello 4 hello 5 hello 6 hello 7 hello 8 hello 9 // 过了5秒 world 0 world 1 world 2 world 3 world 4 world 5 world 6 world 7 world 8 world 9