There are a number of ways you can do it.

You could create a task that does an amount of work that takes well under 30
seconds to run.. and whenever it completes, it just adds itself back to the
taskqueue.

Or, as you mention, just make it so that your task just keeps running until
the DeadlineExceededError error is thrown.. and This is very important, once
you catch that error, you add a new task to the Queue and allow the running
task to quietly succeed.

One thing you do not want to do:  don't just let the task run and fail and
restart again.. it will just start at later and later times due to the
backoff.

Here is an example in the docs of doing background work with mapper that
uses the DeadlineExceededError as a cue to finish up:

http://code.google.com/appengine/articles/deferred.html
<http://code.google.com/appengine/articles/deferred.html>

On Wed, Aug 18, 2010 at 5:51 PM, Alon Carmel <[email protected]> wrote:

> thats what im asking. can i re-instate recursively a task every time it
> fails dues making the task run forever?
> -
> Cheers,
>
> def AlonCarmel(request)
>      import simplejson as json
>      contact = {}
>      contant['email'] = '[email protected]'
>      contact['twitter'] = '@aloncarmel'
>      contact['web'] = 'http://aloncarmel.me'
>      contact['phone'] = '+972-54-4860380'
>      return HttpResponse(json.dumps(contact))
>
> * If you received an unsolicited email from by mistake that wasn't of your
> matter please delete immediately. All E-mail sent from Alon Carmel is
> copyrighted to Alon Carmel 2008. Any details revealed in e-mails sent by
> Alon Carmel are owned by the Author only. Any attempt to duplicate or
> imitate any of the Content is prohibited under copyright law 2008.
>
>
>
> On Thu, Aug 19, 2010 at 12:22 AM, MyElasticEye <[email protected]>wrote:
>
>> Why don't you just add that task to a queue and if it fails, it will
>> automatically re-execute itself and run again in a few minutes.
>>
>> On Aug 19, 12:00 am, alon <[email protected]> wrote:
>> > Hey,
>> > I need to keep a task running and monitoring twitter stream api.
>> >
>> > Is it possible to initiate a task that does
>> >
>> > try
>> >
>> > catch DeadlineExceededException
>> >
>> > task.add the same task again?
>> >
>> > so basically the task will always rerun itself over and over and over
>> > indefinitely? i dont mind it ending after 30 seconds at a time or even
>> > less but atleast i can keep on monitoring the stream 30 seconds at a
>> > time.
>> >
>> > is that possible?
>>
>> --
>> 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]<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