django-cloudtask
A django package for managing long running tasks via Cloud Run and Cloud Scheduler
Should I be using this package?
Not yet - we're still trying to make this package usable by the general public.
There are a lot of assumptions being made that might not be suitable for your project.
Usage
Setup
include django_cloudtask in your installed apps.
Configuration
Make sure these are in your django settings:
PROJECT_ID- the GCP project
PROJECT_REGION- GCP region
TASK_SERVICE_ACCOUNT- Service account which will be authenticated against
TASK_DOMAIN- domain which receives tasks (cloud run)
TASK_DEFAULT_QUEUE- default queue tasks will be added to
Defining a task
Tasks must be defined in a file called tasks.py at the root level of an app directory.
e.g.,
my-project/
app/
tasks.py
urls.py
views.py
manage.py
settings.py
Tasks are defined using the @register_task decorator.
@register_task(should_retry: bool, queue: str, schedule: str)
:should_retry: Will retry the task if there was an uncaught exception
:queue: What Queue this task belongs to (Queues are set up in GCP)
:schedule: Cron-like string defining when this task should be executed
Note: a scheduled task cannot have any arguments (but can have kwargs with defaults).
e.g.,
from django_cloudtask import register_task
@register_task
def my_task(some, args, kwarg=False):
...
@register_task(schedule="0 5 * * *")
def scheduled_task():
...
Calling a task
Tasks may be scheduled by calling enqueue(*args, **kwargs).
args and kwargs must be JSON serialisable.
Tasks may also be called directly which will execute in the current call stack.
e.g.,
# execute asynchronously
my_task.enqueue(1, "start the task", kwarg=True)
# execute immediately
scheduled_task()
Contributing
We use pre-commit <https://pre-commit.com/> to enforce our code style rules
locally before you commit them into git. Once you install the pre-commit library
(locally via pip is fine), just install the hooks::
pre-commit install -f --install-hooks
The same checks are executed on the build server, so skipping the local linting
(with git commit --no-verify) will only result in a failed test build.
Current style checking tools:
- flake8: python linting
- isort: python import sorting
- black: python code formatting
Note:
You must have python3.6 available on your path, as it is required for some
of the hooks.
Metadata
Release files for django-cloudtask 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-cloudtask-0.1.5.tar.gz | 8.6 kB | Without provenance | Details for django-cloudtask-0.1.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_cloudtask-0.1.5-py3-none-any.whl | Python 3 | none | any | Details for django_cloudtask-0.1.5-py3-none-any.whl |
Total release size: 17.3 kB
Release files / django-cloudtask-0.1.5.tar.gz
| Download URL | django-cloudtask-0.1.5.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
65e68a1de81b4734b374d6f60d8fb1f1b549da7bb94b6b12c1d6cbab89525d22
|
|
BLAKE2b-256 checksum How to use checksums |
4ed6cdc432ed9b4fece52d0c70d874a32cb5d8e7a1e8ae981595dcf531d04003
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.0 Darwin/19.6.0
|
Release files / django_cloudtask-0.1.5-py3-none-any.whl
| Download URL | django_cloudtask-0.1.5-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4fd5bc2ca8245adafda636cdab252c53d5449543f601a72510f5c98b0c6e6837
|
|
BLAKE2b-256 checksum How to use checksums |
0be5ee3fc46533e4262a610c64db6c68668b9c411ca978141bed6f4d3285033f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.8.0 Darwin/19.6.0
|
Security for django-cloudtask 0.1.5
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.