V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wchluxi
V2EX  ›  Django

Django 如何获取 apscheduler 的 scheduler 实例?

  •  
  •   wchluxi · 2022-01-19 13:53:10 +08:00 · 1706 次点击
    这是一个创建于 799 天前的主题,其中的信息可能已经有所发展或是发生改变。

    背景

    nginx+uwsgi+django 框架下,用 django-apscheduler 定时执行任务,但我的任务是保存在内存(MemoryJobStore),不能用数据库保存(因为数据库用的是 sqlite ,任务本身需要读取读写数据库,会造成 database is locked 导致后面任务不执行)。

    问题

    怎么获取到 scheduler 实例?因为现在不确定是否添加了任务,原来在本地 debug 下将 scheduler 设成全局变量,通过全局变量和 get_jobs()方法是可以获取到任务列表,但这个方法貌似在服务器的生产环境上用不了。

    有大神提一下建议吗?

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1133 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:43 · PVG 02:43 · LAX 11:43 · JFK 14:43
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.