[英]async apscheduler does not start the task
嘗試創建調度程序:
sheduler = AsyncIOScheduler(timezone='Europe/Moscow')
async def thread_maintaining_communication():
print('There')
async def main():
sheduler.add_job(thread_maintaining_communication,"interval", seconds=20)
sheduler.start()
#await bot.infinity_polling(skip_pending=True)
while True:
print('sleep 10 sec')
await asyncio.sleep(10)
asyncio.run(main())
但是由於某種我不知道的原因,它不起作用。 這是控制台中的內容:
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
INFO:apscheduler.scheduler:Added job "thread_maintaining_communication" to job store "default"
sleep 10 secINFO:apscheduler.scheduler:Scheduler started
sleep 10 sec
sleep 10 sec
sleep 10 sec
我得到了答案,我希望遇到同樣問題的人能找到這個話題
sheduler.add_job(thread_maintaining_communication,"interval", seconds=20)
bot.add_custom_filter(asyncio_filters.StateFilter(bot))
sheduler.start()
loop = asyncio.get_event_loop()
loop.run_until_complete(bot.polling(skip_pending=True))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.