Skip to main content

This is forked from FreshPlanet’s improved App Engine Deferred module. and has the added functionality of having a Django View along with the webapp2 handler so that it can be used in either project type.

The AppEngine Python SDK has a great module when it comes to easily run some code “later”: the deferred library (if you are unfamiliar with this library, please have a look at its documentation first).

However the library has a few drawbacks that we solve here:

  • No asynchronous method (issue 9530)

  • The internal request handler inherits from webapp instead of webapp2 which can be an issue when using some webapp2 features (like webapp2.get_request)

  • It uses pickle instead of leveraging cPickle available with the Python 2.7 runtime.

  • The Route it uses is internal and will skip your middlewares unless you define them in a special appengine_config.py module.

  • Task could fail to properly execute when hitting a fresh instance which did not had all code loaded

  • Logging is a bit verbose: it uses the INFO level to show task headers that are redundant with what we can see by default in the AppEngine logs

We also added a couple of features to it:

  • Explicit URLs for tasks: instead of just seeing /_ah/queue/deferred in your logs you will see something like /_cb/deferred/app.module.name/funcName

  • Possibility to spread tasks over several queues in case of high throughput

  • Improved logging in case of error

  • Possibility to tie it to a background module to optimize serving requests

And some helpers: - is_from_task_queue(): Check if we are currently running from a task queue - get_retry_count(): Returns the current number of times the current task is being retried - log_as_retried(): Depending on # of times the task is being retried, we will increase the logging level.

Our module still makes use of the deferred exceptions types `SingularTaskFailure` and `PermanentTaskFailure` to be compatible with existing code.

Installation

  1. pip install fh-django-gae-tasks

  2. Load the app in your Django project’s settings.py

INSTALLED_APPS = (
    'gae_tasks'
)
  1. Load the URL for the app

urlpatterns = [
    url(r'^', include('gae_tasks.urls')),
]
  1. Optionally, better integrate with your application by updating the tasks settings:

GAE_TASKS_DISABLE: False
GAE_TASKS_WARMUP_MODULE: None
GAE_TASKS_DEFAULT_QUEUES: ['default']
GAE_TASKS_BACKGROUND_MODULE: None

(See the tasks module for more details)

Metadata

Release files for fh-django-gae-tasks 0.2.4

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

Source distribution (sdist)

Source distribution for fh-django-gae-tasks 0.2.4
File Size Uploaded Provenance Actions
fh-django-gae-tasks-0.2.4.tar.gz 6.8 kB Without provenance Details for fh-django-gae-tasks-0.2.4.tar.gz

Release files / fh-django-gae-tasks-0.2.4.tar.gz

Download URL fh-django-gae-tasks-0.2.4.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c4d8053e7d8f4872acaeacd1053f2cb844b1bdc71d87d1f9138d9be3231aaeef
BLAKE2b-256 checksum
How to use checksums
46cc39bbc8261bef11fa0384015c4cbae24b3cf9deea5cefac31cbf9b93025db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for fh-django-gae-tasks 0.2.4

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.

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