celery的options中expires

CELERYBEAT_SCHEDULE: In each task, you can add an ‘options’ dictionary and set ‘expires’ to a number of seconds. If the task doesn’t run within that time, it’ll be discarded rather than run when it finally gets to a worker. This can help a lot with periodic tasks when workers or the queue gets hung up for a while and then unjammed – without this, the workers will have to work through a huge backlog of the same periodic tasks over and over, for no reason.

Example:

CELERYBEAT_SCHEDULE = {
    'process_new_scans': {
        'task': 'tasks.process_new_scans',
        'schedule': timedelta(minutes=15),
        'options': {
            'expires': 10*60,  # 10 minutes
        }
    },
}

发表评论

您的电子邮箱地址不会被公开。