Celery: a standard method for requesting unsolved problems?

Is there a standard / base-independent method for requesting pending tasks based on specific fields?

For example, I have a task that should run once after the โ€œlast user interactionโ€, and I would like to implement it somehow like:

def user_changed_content(): task = find_task(name="handle_content_change") if task is None: task = queue_task("handle_content_change") task.set_eta(datetime.now() + timedelta(minutes=5)) task.save() 

Or is it easier to connect directly to the storage server?

+8
python celery
source share
1 answer

No, It is Immpossible.

Even if some transports may support queue access out of order (for example, Redis), this is not a good idea.

The task can no longer be in the queue and is instead reserved by the worker.

See this part in the documentation: http://docs.celeryproject.org/en/latest/userguide/tasks.html#state

Given that the best solution would be to check if it should transfer itself at startup:

 @task def reschedules(): new_eta = redis.get(".".join([reschedules.request.task_id, "new_eta"]) if new_eta: return reschedules.retry(eta=new_eta) 
+9
source share

All Articles