gaetk2.tools.taskqueue - access App Engine taskqueues

This are convinience functions to work with App Engine taskqueues. Also defer() provides much better error reporting See Error Handling Guide.

Module contents

gaetk2.taskqueue.taskqueue_add_multi(qname, url, paramlist, **kwargs)[source]

Adds more than one Task to the same Taskqueue/URL.

This helps to save API-Calls. Usage pattern:

tasks = []
for kdnnr in kunden.get_changed():
    tasks.append(dict(kundennr=kdnnr))
taskqueue_add_multi('softmq', '/some/path', tasks)
gaetk2.taskqueue.taskqueue_add_multi_payload(name, url, payloadlist, **kwargs)[source]

like taskqueue_add_multi() but transmit a json encoded payload instead a query parameter.

In the Task handler you can get the data via zdata = json.loads(self.request.body). See http://code.google.com/appengine/docs/python/taskqueue/tasks.html

gaetk2.taskqueue.defer(obj, *args, **kwargs)[source]

Defers a callable for execution later.

like https://cloud.google.com/appengine/articles/deferred but adds the function name to the url for easier debugging.

Add this to app.yaml:
handlers:

# needed to allow abritary postfixes and better error handling - url: /_ah/queue/deferred(.*)

script: gaetk2.views.default.application login: admin

Parameters starting with _ are handed down to taskqueue.add()

gaetk2.taskqueue.defer_once_per_hour(obj, *args, **kwargs)[source]

Like defer() but only once per hour.

Executes the same function with the same parameters not more often than once per hour. The heuristic for doing so are not exact so do not rely on this mechanism for anything importatant.

This is more for updating cloud services with statistics etc.

gaetk2.taskqueue.defer_once_per_day(obj, *args, **kwargs)[source]

Like defer_once_per_hour() but only once per day.