python 异步apscheduler不启动任务

vohkndzv  于 2022-12-02  发布在  Python
关注(0)|答案(1)|浏览(186)

正在尝试创建计划程序:

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
anauzrmj

anauzrmj1#

我得到了一个答案,我希望面对同样问题的人会找到这个主题

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))

相关问题