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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-task-api-1.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 7be71055a9ec657f5f82d9df616a77e214b10279f4171caa97fa1994e3a1002a
MD5 c5d5f8a6f1776f9dbcff4d33deede0e8
BLAKE2b-256 30bc51022fdff8363b763bcb4403312d5d5e1985add4fde4aa14a805aa40fd5f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: django_task_api-1.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6ed8cbb5480122cbe9fd437f4870212d2ec40c115cfc63cc246b3088fe1668c3
MD5 c6271dbe322d1303ca9c078696ba9edd
BLAKE2b-256 72326fd847d95a0364ba5458f43952eaa4beed3138bd26ce8d23912fe95e942c

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