How can I run an async function using the schedule library?

后端 未结 5 938
广开言路
广开言路 2020-11-29 10:52

I\'m writing a discord bot using discord.py rewrite, and I want to run a function every day at a certain time. I\'m not experienced with async functions at all and I can\'t

5条回答
  •  渐次进展
    2020-11-29 11:13

    This is an old question, but I recently ran into the same issue. You can use run_coroutine_threadsafe to schedule a coroutine to the event loop (rather than a callback):

    asyncio.run_coroutine_threadsafe(async_function(), bot.loop)
    

提交回复
热议问题