Vu1nT0tal / yarb

方便获取每日安全资讯的爬虫和推送程序
https://vulntotal-team.github.io/yarb/
GNU General Public License v3.0
657 stars 229 forks source link

定时任务出错 #26

Open Stansec233 opened 8 months ago

Stansec233 commented 8 months ago
❯ python3.9 yarb.py --cron 13:59
/usr/local/python3.9/lib/python3.9/site-packages/schedule/__init__.py:100: RuntimeWarning: coroutine 'job' was never awaited
  self._run_job(job)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

bot 就用了企业微信机器人,改了 key,请问是哪里出问题

Freedom1203 commented 4 months ago

async def main():

args = argument()  # 假设这是获取参数的函数
if args.cron:
    # 使用 lambda 封装异步调用,因为 schedule 库不支持直接使用 await
    schedule.every().day.at(args.cron).do(lambda: asyncio.create_task(job(args)))
    while True:
        schedule.run_pending()
        await asyncio.sleep(1)
else:
    # 直接调用异步 job 函数
    await job(args)

尝试这样改,可以运行