Skip to main content

Library that provides a system to generate tasks producers and consumers with ease.

Project description

Version:
1.1.1
Status:
Production/Stable
Author:

José Antonio Perdiguero López

Library that provides a system to generate tasks producers and consumers with ease.

Celery is used as backend, so it’s necessary to configure it in the application where this library will be used.

To achieve a producer-consumer behavior this library provides an easy to use script for running all necessary processes:

  • Producer: Tasks in charge of generating processing units.

  • Consumer: Tasks that handle and run processing units.

  • Scheduler: Manager that runs producer tasks according to specified dates or regularity.

Quick start

  1. Install this package using pip:

    pip install task-dispatcher
  2. Decorate your functions as producer and consumer tasks:

    from task_dispatcher import consumer, producer
    
    
    @consumer
    def square(x):
        return x**2
    
    
    @producer
    def prod_function(n):
        for i in range(n):
            square.delay(i)
  3. Run producer, consumer and scheduler processes:

    python task-dispatcher producer
    python task-dispatcher consumer
    python task-dispatcher scheduler

Consumer and Producer

This library provides convenient decorators for generating a task dispatcher system based on producer-consumer pattern. Decorated functions or methods acts as Celery tasks and can be called using his own syntax: Calling celery tasks. Also, it’s possible to compose these tasks using Celery Canvas.

Register

Consumer and producer tasks are registered to ease the way of access them. There is a register module that contains the task register where all tasks can be found:

from task_dispatcher import register

# Get consumers
register.consumers

# Get produces
register.producers

Also, this register provides a set of utilities, such as convert it into JSON or YAML format:

from task_dispatcher import register

yaml_register = register.to_yaml()
json_register = register.to_json()

Command Line Interface

There is a script that can be called directly through executing the task_dispatcher package itself or the command located in commands module. To show command help:

python task-dispatcher -h

This script also gives a friendly way of list all tasks registered:

python task-dispatcher list

Django

This library can be imported and used as a Django application instead of a plain library, so that the CLI script also acts as a Django command.

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

task-dispatcher-1.1.1.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

task_dispatcher-1.1.1-py2.py3-none-any.whl (10.5 kB view details)

Uploaded Python 2Python 3

File details

Details for the file task-dispatcher-1.1.1.tar.gz.

File metadata

File hashes

Hashes for task-dispatcher-1.1.1.tar.gz
Algorithm Hash digest
SHA256 189e49f8ae223f5ed7bd3b4c0627b766979f558415ee542ed4e83c56e517f7d3
MD5 5d62dacaf6599d08336bd05b96345cca
BLAKE2b-256 c688699498cbb78589e9c25e5d512fa6b9986138f8845faaed2bfba7f050a41f

See more details on using hashes here.

File details

Details for the file task_dispatcher-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for task_dispatcher-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 0df99765a3c787139deb7af740aeabc69828140a280a1c19f471814d70268dc4
MD5 fe0be2d8e4c5c86ea4262a1cb064eb58
BLAKE2b-256 7abd1f1e4f1f1a4ce9cd842dac445ab102674a45247d3bc5fa196d4004c4e669

See more details on using hashes here.

Supported by

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