0

When adding a certain task to the task queue, I would like to make sure there is only one such task. If this task already exists, I would like to delete it and add the new task instead (postponing its execution is ok also). This is my code:

queue = taskqueue.Queue()
queue.delete_tasks_by_name('task_name')
task = taskqueue.Task(
    name = 'task_name',
    url = '/task/url',
    method = 'GET',
    countdown = 3600)
queue.add(task)

When running the code it raises a TombstonedTaskError, which make sense according to the docs. Is there a way to replace or postpone execution of an existing task?

Tzach
  • 12,889
  • 11
  • 68
  • 115

1 Answers1

0

Use tags instead of names. Give the tag a unique name then do a lease_task_by_tag to see if it exists.

add(taskqueue.Task(payload='parse1', method='PULL', tag='parse')) lease_tasks_by_tag(lease_seconds, max_tasks, tag=None, deadline=10)

Ryan
  • 2,512
  • 1
  • 13
  • 20
  • Thanks but `lease_tasks_by_tag` applies only to pull queue tasks. My task are push queue tasks. – Tzach Jan 12 '15 at 15:39