起因:有的时候。我们希望任务具有时效性。比方定时每5分钟去抓取某个状态,由于celery队列中的任务可能非常多,等到这个任务被运行时。已经超过了5分钟,那么这个任务的运行已经没有意义。由于下一次抓取已经运行了。

能够进行例如以下设定:

@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.

当任务被取出是超过900 秒,任务会直接revoke , 任务会被跳过,不会被运行

以下是celery的日志

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]

可以看到任务已经被撤销了。

celery expires 让celery任务具有时效性的更多相关文章

  1. celery 分布式异步任务框架(celery简单使用、celery多任务结构、celery定时任务、celery计划任务、celery在Django项目中使用Python脚本调用Django环境)

    一.celery简介: Celery 是一个强大的 分布式任务队列 的 异步处理框架,它可以让任务的执行完全脱离主程序,甚至可以被分配到其他主机上运行.我们通常使用它来实现异步任务(async tas ...

  2. Airflow 配置celery+rabbitmq和celery+redis

    Airflow 配置celery+rabbitmq 1.安装celery和rabbitmq组件 pip3 install apache-airflow[celery] pip3 install apa ...

  3. 使用celery之深入celery配置(转)

    原文:http://www.dongwm.com/archives/shi-yong-celeryzhi-shen-ru-celerypei-zhi/ 前言 celery的官方文档其实相对还是写的很不 ...

  4. 使用celery之了解celery(转)

    原文  http://www.dongwm.com/archives/shi-yong-celeryzhi-liao-jie-celery/   前言 我想很多做开发和运维的都会涉及一件事:cront ...

  5. 在tornado中使用celery实现异步任务处理之中的一个

    一.简单介绍 tornado-celery是用于Tornado web框架的非堵塞 celeryclient. 通过tornado-celery能够将耗时任务增加到任务队列中处理, 在celery中创 ...

  6. Python 任务队列 Celery

    一. celery 简介 Celery 是一个专注于实时处理和任务调度的分布式任务队列, 同时提供操作和维护分布式系统所需的工具.. 所谓任务就是消息, 消息中的有效载荷中包含要执行任务需要的全部数据 ...

  7. Python Celery队列

    Celery队列简介: Celery 是一个 基于python开发的分布式异步消息任务队列,通过它可以轻松的实现任务的异步处理, 如果你的业务场景中需要用到异步任务,就可以考虑使用celery. 使用 ...

  8. Celery(四)定时任务

    要定时或者周期性的执行任务,可以使用linux的crontab.Celery也提供了类似的Periodic Tasks功能. Celery beat Celery使用celery beat作为任务调度 ...

  9. Celery 分布式任务队列快速入门

    Celery 分布式任务队列快速入门 本节内容 Celery介绍和基本使用 在项目中如何使用celery 启用多个workers Celery 定时任务 与django结合 通过django配置cel ...

随机推荐

  1. HDU Traffic Real Time Query System

    题目大意是:对于(n, m)的图,给定边a, b查询从a到b要经过的割点的最少数目. 先tarjan算法求双连通然后缩点,即对于每个割点将周围的每个双连通看成一个点与之相连.然后求解LCA即可,距离d ...

  2. objective-c 强大的布尔类型

    objective-c codes: #import <Foundation/Foundation.h> BOOL areIntsDifferent(int thing1,int thin ...

  3. Python解决codeforces ---- 1

    第一题 1A A. Theatre Square time limit per test 2 seconds memory limit per test 64 megabytes input stan ...

  4. 加载网络映射盘中的assembly失败的处理办法

    错误症状: 1.{"未能加载文件或程序集“file://*****”或它的某一个依赖项.不支持操作. (异常来自 HRESULT:0x80131515)":"file:/ ...

  5. C#中的ODBC、OLEDB连接

      using System;using System.Collections.Generic;using System.Text;using System.Data.Odbc;using Syste ...

  6. IPv6 tutorial 1 Get started now

    https://4sysops.com/archives/ipv6-part-1-get-started-now/ You’ve probably heard the news that the In ...

  7. poj3140Contestants Division

    链接 这叫树形DP吗..?断开某条边 求剩下两颗树数权值和的差最小 dfs一遍 枚举边 查了n久 wa n次  dp数组没初始化.. 在poj上1A感觉应该挺爽 #include <iostre ...

  8. c语言实用功能库函数#include<stdlib.h>

    实用函数<stdlib.h> 在头文件<stdlib.h>中说明了用于数值转换.内存分配以及具有其他相似任务的函数. 1 atof #include <stdlib.h& ...

  9. Xcode6新建的工程没有Frameworks文件夹了?!原来是这样

    http://stackoverflow.com/questions/24181062/default-frameworks-missing-in-xcode-6-beta They are impo ...

  10. MySql配置参数很全的Mysql配置参数说明

    MySql配置参数 很全的Mysql配置参数说明 1. back_log 指定MySQL可能的连接数量.当MySQL主线程在很短的时间内得到非常多的连接请求,该参数就起作用,之后主线程花些时间(尽管很 ...