V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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 · Aug 27, 2019 · 2704 views
    This topic created in 2445 days ago, the information mentioned may be changed or developed.

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

    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,故没法删除。

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

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5002 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 05:38 · PVG 13:38 · LAX 22:38 · JFK 01:38
    ♥ Do have faith in what you're doing.