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.0.tar.gz (72.6 kB view details)

Uploaded Source

Built Distribution

django_task_api-1.1.0-py3-none-any.whl (75.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-task-api-1.1.0.tar.gz
  • Upload date:
  • Size: 72.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for django-task-api-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3df84cf5d17d2cd07f911965335375d13d407b23c1a572f46c68489740bc64a3
MD5 8a4232a2b5e2b4a5b4728213b81a0bbf
BLAKE2b-256 cbbd22c0022c4b56699d3494c8ad8c3ee30d722bc5e7779346a2f14a543d4b42

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_task_api-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 75.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for django_task_api-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac72342639fc8c1ac2560639c5a29e94514786bfb3c3d139ba59f44ee8bc0bdc
MD5 80502571b10f5a618ba811094323c98a
BLAKE2b-256 6f497383228331b06404dd8a0241ddf29f7f6636eccc63557ee8ae260064afe4

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