Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

用户如何自定义异步任务? #35

Closed
VacantHusky opened this issue Oct 31, 2021 · 1 comment
Closed

用户如何自定义异步任务? #35

VacantHusky opened this issue Oct 31, 2021 · 1 comment

Comments

@VacantHusky
Copy link

翻阅Yiri的源码,发现MiraiRunner类的run方法里有:

try:
    asyncio.run(self._run())
except (KeyboardInterrupt, SystemExit):
    exit()

现在我有一个自己写的异步任务:

async def test():
    while 1:
        print("hello")
        await asyncio.sleep(3)

我该如何加进去?

@Wybxc
Copy link
Collaborator

Wybxc commented Oct 31, 2021

在0.2.6之后,YiriMirai有了 add_backgroud_task 功能。

具体用法请参考文档:https://yiri-mirai.wybxc.cc/docs/basic/background_task

@Wybxc Wybxc closed this as completed Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants