设置任务60s执行一次,但是看log发现10s内执行了两次?
zxcvbn001 opened this issue · 4 comments
zxcvbn001 commented
定时任务写法:
fsdf_background_scheduler.add_job(timing_publish_deco(xxx_spider), 'interval', id='xxx_add_queue', seconds=300)
fsdf_background_scheduler.add_job(timing_publish_deco(xxx_result), 'interval', id='xxx_result_queue', seconds=60)
日志:RedisConsumer--xxx_result_queue - "base_consumer.py:697" - INFO - 10 秒内执行了 2 次函数 [xxx_result ] ,函数平均运行耗时 0.009 秒
消费者:
xxx_spider.consume()
xxx_result.consume()
ydf0509 commented
那就先清空消息队列。
zxcvbn001 commented
怎么清空来着
ydf0509 commented
xxx_spider.clear() 或者用redis命令删除消息队列的键。
zxcvbn001 commented
好的,问题解决了,现在看着还是说执行了两次,但是写入到数据库的结果没有重复了,感谢!