You just need to add a try: except: (if you're using Python) to handle
TombstonedTaskError and TaskAlreadyExistsError.

I use a taskadd function that looks like this:

def taskAdd(name,counter,delay=0,wait=.5):
    try:
        taskqueue.add(name = name,url = '/mytasks/doTask',
                      countdown = delay, params = {'counter' : counter} )
    except (taskqueue.TaskAlreadyExistsError,
taskqueue.TombstonedTaskError), e:
        pass
    except:
        from time import sleep
        sleep(wait)
        taskAdd(name,counter,delay,2*wait)

Once a task is done.. it adds a new one back to the queue like so:

counter = int(self.request.get('counter')) + 1
taskAdd(name+str(counter),counter)

That way.. if you get any error besides one indicating the Task is already
there.. it just tries to add the task again a little later.

Of course.. you give it whatever delay you want.. in case you don't want it
to start immediately.

On Mon, Feb 22, 2010 at 10:23 AM, Iap <[email protected]> wrote:

> Hi,
>
> In my application, I have to pool the datestore every 3 seconds for
> updating states.
> I implement this pooling into taskqueue as a task.
> For every execution, the task gets the job done and add itself to the
> taskqueue for next execution.
> Something like recursive execution.
>
> The problem is that after a certain period, from one hour to several
>  hours,
> the number of tasks grows up. I understand that it is because the
> auto-retry of the taskqueue.
> Because of the TombStonedError, I can not assign name to task for
> preventing the duplication.
> Also, I have no idea to handle the TransientError. The document says
> to retry again later.
> Because this is a background running process, the question is "how to
> be later?",
> Put it in taskqueue! Then, I am like a python which swallow its own tail.
>
> In javascript, ActionScript, there are "setTimeout" and "setInterval"
> for one-time tasks and looping tasks.
> In Twisted/Python, there are reactor.callLater and task.LoopingCall
> for the both too.
>
> How to do looping task in the taskqueue correctly?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to