chustar
chustar

Reputation: 12465

Update App Engine Tasks?

Is it possible to update an AppEngine task in the task queue?
Specifically, changing the eta property of the task to make it run at a different time?

In my scenario, each item in my datastore has an associated task attached to it. If the element is updated, the task needs to updated with a new eta.

I currently set the name of the task explicitly as the id of the item using name=item.key().id() so that I can uniquely refer to the task.

When the task is called and deleted, the name doesn't get freed immediately (I think). This causes issues because I need to re-add the task as soon as it gets executed.

Upvotes: 2

Views: 318

Answers (2)

chustar
chustar

Reputation: 12465

So I resolved this in the following way:
I created an entry in my Model for a task_name. When I create the element and add a new task, I allow app engine to generate an automated, unique name for the task then retrieve the name of that task and save it with the model.

This allows me to have that reference to the task.

When I need to modify the task, I simply delete the existing one, create a new one with the new eta and then save the new task's name to the model.

This is working so far, but there might be issues in the future regarding tasks not being consistent when the Task.add() function returns.

Upvotes: 1

Eric Willigers
Eric Willigers

Reputation: 1806

With pull queues, you can use modify_task_lease to set the ETA relative to the current time (even if you do not currently have the task leased).

You can't change the ETA of a pull queue task.

Each task's name remains unavailable for seven days.

Upvotes: 1

Related Questions