繁体   English   中英

async apscheduler 不启动任务

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM