V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Raul7
V2EX  ›  Python

apscheduler 的一次性任务(trigger='date')运行状态时该怎么停止?

  •  
  •   Raul7 · 2019-08-27 14:44:54 +08:00 · 2331 次点击
    这是一个创建于 1675 天前的主题,其中的信息可能已经有所发展或是发生改变。

    写了个停止的方法(先暂停再删除任务),

    def stop_task():
           print(scheduler.get_jobs())
           scheduler.pause_job('job_id')
           scheduler.remove_job('job_id')
           return "success"
    

    trigger='cron'和 trigger='interval'的任务我都能直接获取到 job_id,然后调用 pause_job()可以直接暂停任务。 但是 trigger='date'在运行的时候,获取不到 job_id,故没法删除。

    求助大家,还有其他方法吗?还是说我这样写不对?

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