简体   繁体   English

Celery最佳方式管理/获取任务的eta

[英]Celery best way manage/get eta of task

I want to get eta of task in celery each time with get request. 我想每次通过get请求获取芹菜任务的eta。 There is no direct api in celery to get task scheduled time (except inspect() - but it's seems very costly to me) 芹菜中没有直接的API来获取任务计划的时间(inspect()除外-但对我来说这似乎很昂贵)

How can i manage eta of particular task? 如何管理特定任务的eta? The downside of storing eta time in Django model is not consistent ( either i couldnt store taks_id because i can't - dont know how get eta from task_id) 在Django模型中存储eta时间的缺点是不一致的(我无法存储taks_id,因为我不能-不知道如何从task_id获取eta)

I see on one question that there is no api, cause it somehow depends on brokers and etc. But i hope that there is some solution 我看到一个问题,没有api,导致它某种程度上取决于经纪人等。但我希望有解决方案

So what's the best way manage task_id to get eta? 那么管理task_id以获得eta的最佳方法是什么?

Backend and broker is redis 后端和经纪人是Redis

I don't think there is a magic way to do this. 我认为没有一种神奇的方法可以做到这一点。

What I do in my app is just log the execution time for each task and return that as an ETA. 我在应用程序中所做的只是记录每个任务的执行时间,并将其作为ETA返回。 If you wanted to get a little more accurate you could also factor in the redis queue size and the task consumption rate. 如果您想获得更高的精度,还可以考虑redis队列大小和任务消耗率。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM