Skip to main content

A REST API for managing background tasks in Django

Project description

Django Task API lets you quickly write background tasks for your Django project and easily call then using the provided REST API, or the included JavaScript library.

What does it look like?

Tasks are defined as classes with typed input and output parameters, and a run function with the task implementation, to be called by a worker processes.

from task_api.tasks import Task
from task_api.params import ListParameter, NumberParameter

class SumNumbers(Task):
    name = 'sum'

    inputs = {
        'numbers': ListParameter(NumberParameter())
    }

    outputs = {
        'sum': NumberParameter()
    }

    def run(self, numbers):
        return sum(numbers)

Tasks are easily called and monitored in front-end code using the included JavaScript API. The API supports both promises (will Polyfill for older browsers) and traditional callbacks.

<script src="{% static 'django-task-api.js' %}"></script>

<script type="text/javascript">
    function sumTask(numbers) {
        TaskAPI
            .run('sum', {'numbers': numbers})
            .then(function(json) {
                console.log('Sum: ' + json.outputs.sum)
            })
    }
</script>

Next Steps

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-task-api-1.1.3.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

django_task_api-1.1.3-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file django-task-api-1.1.3.tar.gz.

File metadata

  • Download URL: django-task-api-1.1.3.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.5

File hashes

Hashes for django-task-api-1.1.3.tar.gz
Algorithm Hash digest
SHA256 39438aa6b5c15abc5165516c3f8ab6f3c538a94151f3c0fc0e572b080f1b6fd7
MD5 fe1d3f1e3c6f0f4b8d005ba37badde20
BLAKE2b-256 f8b675d8030544ca69293bab10b8a07171a0b0d2f023962e1e4a05a26bc8c203

See more details on using hashes here.

File details

Details for the file django_task_api-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: django_task_api-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.5

File hashes

Hashes for django_task_api-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8c05d396163cba0ebeb09859d5b0e8c1584894de27a93c34375971f5106e90f9
MD5 4c1e636220a8e71c214d9d94a30bb954
BLAKE2b-256 13f49dd3751ac660697e6fbc1ec9f1113c1801fee31f8335bccaead486eaf29d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page