two more questions...

what made you choose taskqueue over cron?

I see from your sample snippet of code that taskqueue will stop being
called when you are sure all rows are processed. How you do kick-start
the process again? and how does it know that a existing taskqueue loop
isn't already cycling through?

On Mar 11, 11:29 pm, howesc <[email protected]> wrote:
> i use taskqueue extensively in my GAE apps.  i have not wrapped it in a way
> that it runs in non-gae environment.  My usages of the taskqueue are for
> things that i can't complete in a single 30 second execution time, so i
> suppose i could put an 'if not GAE run all the processing in one request'
> type statement.
>
> my usual usage pattern (i have a few variations on this, but this is a
> simple example):
>
> def process_lots_of_rows():
>     from google.appengine.api import taskqueue
>
>     last_timestamp = request.vars.last_timestamp or
> datetime.datetime(2010,1,1) #reasonable default for my app
>     limit = 100
>     #get records.  use >= so i don't miss any, don't use ID as they are not
> assigned in strictly increasing fashion
>     rows = db(db.record.created_time >=
> last_timestamp).select(orderby=db.end_user.timestamp,
>                                              limitby=(0,limit))
>
>     for r in rows:
>         r.update_record(bob='fred')
>
>     if len(rows) == limit:
>         #there are probably more to process
>         taskqueue.add(url=URL(r=request))
>
>     return dict(message="did some work")

Reply via email to