Cause: Sometimes we want the task to be time-sensitive, for example, to capture a status every five minutes. because there may be many tasks in the celery queue, when this task is executed, it has been more than five minutes, so the execution of this task is meaningless because the next capture has been executed.
You can perform the following settings:
@task(ignore_result=True, expires=900)def nupdate_influence_by_15min(uid, today=None, if_whole=False):... ...
expires – Either a int, describing the number of seconds, or a datetime object that describes the absolute time and date of when the task should expire. The task will not be executed after the expiration time.
When the task is taken out for more than 900 seconds, the task will directly revoke, and the task will be skipped and not executed
The following is the celery log.
Oct 22 13:53:49 bj-social-celery05 social_celery: [2014-10-21 22:08:03,233: INFO/MainProcess] Got task from broker: social_master.sentiment.tasks.daily_update_wayback_sentiment[fe5f3a82-342d-4173-bd13-60182e88ec4f] expires:[2014-10-21 22:08:59.781945]... ...Oct 22 13:53:49 bj-social-celery05 social_celery: [2014-10-21 22:09:15,846: WARNING/MainProcess] Skipping revoked task: social_master.sentiment.tasks.daily_update_wayback_sentiment[fe5f3a82-342d-4173-bd13-60182e88ec4f]
The task has been canceled.
Celery expires timeliness of celery tasks