celery expires 让celery任务具有时效性
来源:互联网 发布:廊坊市北商网络 编辑:程序博客网 时间:2024/06/05 09:25
起因:有的时候,我们希望任务具有时效性,比如定时每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]
能够看到任务已经被撤销了。
0 0
- celery expires 让celery任务具有时效性
- Celery
- celery
- celery
- Celery
- Celery 分发任务
- celery 异步任务队列
- 任务调度:Celery
- 任务调度利器:Celery
- 任务调度利器:Celery
- 任务调度利器-Celery
- Celery任务调度示例
- Celery定时任务
- 任务调度Celery
- django-celery定时任务
- 异步任务神器 Celery
- Celery定时任务
- Celery 分布式任务队列
- 轻量级 NAND 坏块管理方法分析及改进
- InnoDB数据备份工具--Xtrabackup使用
- MTK6577+Android之音频(audio)移植
- 使用CMake工具生成makefile文件
- Linked Data
- celery expires 让celery任务具有时效性
- 测试2
- tools:context=".MainActivity的作用
- ffmpeg--StreamingGuide
- Extjs4增加Tree节点级选方法,可异步级选
- 如何对dgrid表格中选择的行进行操作
- Android :子Activity 使用dialog 引发的BUG--android.view.WindowManager$BadTokenException: Unable to add wind
- 鸟哥的 iptables
- memcached的大坑,千万别踩