Esempio n. 1
0
 def handle(self, *args, **options):
     try:
         scheduler = PersistentScheduler(
             schedule_filename=settings.CELERY_BEAT_SCHEDULE_FILENAME,
             app=app)
         scheduler.setup_schedule()
     except Exception as error:
         self.stderr.write(
             'Removing corrupted schedule file: {!r}'.format(error))
         self.try_remove(settings.CELERY_BEAT_SCHEDULE_FILENAME)
         self.try_remove(settings.CELERY_BEAT_SCHEDULE_FILENAME + '.db')
         scheduler = PersistentScheduler(
             schedule_filename=settings.CELERY_BEAT_SCHEDULE_FILENAME,
             app=app)
         scheduler.setup_schedule()
"""
查询定时任务调度的数据
"""

import shelve

from celery.beat import PersistentScheduler

from apps.task import celery
from apps.task.settings import beat_schedule_filename

# with shelve.open(beat_schedule_filename) as db:
#     print(db)
#     print(db['entries'])

persistent_scheduler = PersistentScheduler(
    app=celery, schedule_filename=beat_schedule_filename)


def get_schedule():
    return persistent_scheduler.get_schedule()


def set_schedule():
    persistent_scheduler.set_schedule()


def add_schedule():
    persistent_scheduler.add()


if __name__ == "__main__":