Skip to main content
# appenginetaskutils
This is the repo for the appengine task utils library. It generates the appenginetaskutils package

## Install

Use the python package for this library. You can find the package online [here](https://pypi.python.org/pypi/appenginetaskutils).

Change to your Python App Engine project's root folder and do the following:

> pip install appenginetaskutils --target lib

Or add it to your requirements.txt. You'll also need to set up vendoring, see [app engine vendoring instructions here](https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27).

## @task

The most basic element of the taskutils library is task(). This decorator function is designed to be used as a replacement for [deferred](https://cloud.google.com/appengine/articles/deferred).

### Configuring @task

When using deferred you have a builtin to configure in app.yaml to make it work. For taskutils.task, you need to add the following to your app.yaml and/or \<servicename\>.yaml file:

handlers:
- url: /_ah/task/.*
script: taskutils.app
login: admin

This rule creates a generic handler for task to defer work to background push tasks.

Add it at the top of the list (to make sure other rules don't override it).

### Importing task

You can import task into your modules like this:

from taskutils import task

### Using task as a decorator

You can take any function and make it run in a separate task, like this:

@task
def myfunction():
... do stuff ...

Just call the function normally, eg:

myfunction()

You can use @task on any function, including nested functions, recursive functions, recursive nested functions, the sky is the limit. This is possible because of use of [yccloudpickle](https://medium.com/the-infinite-machine/python-function-serialisation-with-yccloudpickle-b2ff6b2ad5da#.zei3n0ibu) as the underlying serialisation library.

Your function can also have arguments, including other functions:

def myouterfunction(mapf):

@task
def myinnerfunction(objects):
for object in objects:
mapf(object)

...get some list of lists of objects...
for objects in objectslist:
myinnerfunction(objects)

def dosomethingwithobject(object):
... do something with an object ...

myouterfunction(dosomethingwithobject)

The functions and arguments are being serialised and deserialised for you behind the scenes.

When enqueuing a background task, the App Engine Task and TaskQueue libraries can take a set of parameters. You can pass these to the decorator:

@task(queue="myqueue", countdown=5)
def anotherfunction():
... do stuff ...

Details of the arguments allowed to Tasks are available [here](https://cloud.google.com/appengine/docs/python/refdocs/google.appengine.api.taskqueue), under **class google.appengine.api.taskqueue.Task(payload=None, \*\*kwargs)**. The task decorator supports a couple of extra ones, detailed below.

### Using task as a factory

You can also use task to decorate a function on the fly, like this:

def somefunction(a, b):
... does something ...

somefunctionintask = task(somefunction, queue="myqueue")

Then you can call the function returned by task when you are ready:

somefunctionintask(1, 2)

You could do both of these steps at once, too:


task(somefunction, queue="myqueue")(1, 2)

### transactional

Pass transactional=True to have your [task launch transactionally](https://cloud.google.com/appengine/docs/python/datastore/transactions#transactional_task_enqueuing). eg:

@task(transactional=True)
def myserioustransactionaltask():
...

### includeheaders

If you'd like access to headers in your function (a dictionary of headers passed to your task, it's a web request after all), set includeheaders=True in your call to @task. You'll also need to accept the headers argument in your function.

@task(includeheaders=True)
def myfunctionwithheaders(amount, headers):
... stuff ...

myfunctionwithheaders(10)

App Engine passes useful information to your task in headers, for example X-Appengine-TaskRetryCount.

### other bits

When using deferred, all your calls are logged as /_ah/queue/deferred. But @task uses a url of the form /_ah/task/\<module\>/\<function\>, eg:

/_ah/task/mymodule/somefunction

which makes debugging a lot easier.







Metadata

Release files for im-futuregcscompose 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for im-futuregcscompose 0.1.1
File Size Uploaded Provenance Actions
im_futuregcscompose-0.1.1.tar.gz 4.7 kB Without provenance Details for im_futuregcscompose-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for im-futuregcscompose 0.1.1
File Interpreter ABI Platform Actions
im_futuregcscompose-0.1.1-py2.py3-none-any.whl Python 3, Python 2 none any Details for im_futuregcscompose-0.1.1-py2.py3-none-any.whl

Total release size: 12.5 kB

Release files / im_futuregcscompose-0.1.1.tar.gz

Download URL im_futuregcscompose-0.1.1.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ceff211e0777a95e81b8a69284e00f02a9eb27ae64b490ab564e74544e4ed4dd
BLAKE2b-256 checksum
How to use checksums
e6c327365a0869b5c900f49317b9b4a8251f861399417d31578c3a2514f1d8e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / im_futuregcscompose-0.1.1-py2.py3-none-any.whl

Download URL im_futuregcscompose-0.1.1-py2.py3-none-any.whl
Size 7.8 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
c75f083dab7c120fd855cc4c82768a8691e4144da36bfb628e7d86be693effa3
BLAKE2b-256 checksum
How to use checksums
51751f77b693b3c153e6b37db370aee5481f4d02054cb498127889c14d0bba90
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for im-futuregcscompose 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page