celery expires 让celery任务具有时效性
任务 具有 Celery
2023-09-14 09:10:07 时间
起因:有的时候。我们希望任务具有时效性。比方定时每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]
可以看到任务已经被撤销了。
相关文章
- 视频号直播预告:【任务解说】灯塔大数据分析套件体验挑战赛:72h填满控制台
- 利用定时任务实现宝塔面板随机密码
- 这个深度学习库能执行10多种图像文本任务,有20多个数据集,还统一接口|已开源
- SpringBoot中的定时任务的同步与异步你确定真的知道?
- 使用Isaac Gym 来强化学习mycobot 抓取任务
- Spring Cloud Task 任务开发-实现任务处理逻辑(一)
- Oracle自动化:轻松实现任务运行(oracle自动执行)
- Linux下实现定时自动任务(linux下的定时任务)
- SQL Server 迎接你的任务——装载肩上的包(sqlserver 肩包)
- Oracle Job任务快速自动完成定时任务(oracle job任务)