0
votes

After the finishing a task, celery writes it in to redis. However, the key of the entry is determined by celery itself(I think it is the task id). I want to give specific names because that's how other services know their place.

In my code there is one producer that creates the tasks and many workers. Right now I use tasks_name.get() after all tasks get completed and create new redis entries with my naming convention. But that is that seems so unnecessary and slow. Celery should just use my convention.

I am thinking about renaming them but if this is feasible. How can I receive ids from producer. Maybe some custom RedisBackend class but that is too deep.

1
Shouldn't other services just know the task ID instead, so they can use the Celery API to request and decode the result value?AKX

1 Answers

1
votes

You can give the task a custom ID using task_id parameter when submitting the task. It's supported by apply and apply_async methods of Celery task and send_task method of Celery class.