Skip to main content

Django application. It's a simple system to process queue task in real time.

Project description

It’s a simple system to process queue task in real time.

Requirements

  • python 2.7

  • Django 1.6 through Django 1.9

  • django-redis-cache

Install

  1. Download it from PyPi with pip install django-async-tasks

  2. Add “async_tasks” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'async_tasks',
    )
  3. Configure settings

  • Set setting name that defined for Redis in settings.CACHES. The default used ‘default’ setting name.

    ASYNC_TASKS_REDIS_SETTING_NAME = 'default'
  • Setup log path and log filename. The default used for path os.path.join(BASE_DIR, 'logs') and filename 'async-tasks.log'.

    ASYNC_TASKS_LOG_PATH = os.path.join(BASE_DIR, 'logs') # Log path
    ASYNC_TASKS_LOG_FILENAME = 'async-tasks.log' # Log filename
  1. Add cron job to execute every minute:

    python manage.py django_async_tasks

How to use?

  1. Add task to execute delayed_task(your_function, **params), return identification code

  2. Check is task ready ready_task(identification_code). Return statuses: 'PROCESS', 'SUCCESS', 'FAIL'

  3. Get result result_task(identification_code)

Example

from async_tasks.utils import delay_task, ready_task, result_task

def test(a, b):
    return a + b

def test_delay_task():
    idn = delay_task(test, **{'a': 1, 'b': 2})
    status = None
    while status not in ['SUCCESS', 'FAIL']:
        status = ready_task(idn)

    if status == 'SUCCESS':
        print result_task(idn)
    else:
        print status


if __name__ == "__main__":
    test_delay_task()

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-async-tasks-0.1.1.tar.gz (13.2 kB view details)

Uploaded Source

File details

Details for the file django-async-tasks-0.1.1.tar.gz.

File metadata

File hashes

Hashes for django-async-tasks-0.1.1.tar.gz
Algorithm Hash digest
SHA256 c8409e090540266da4122f3a727883f209604d2ccbd5ea294c3853cd16a3b09f
MD5 aa3b68a3ad2eb65a6f16dd3fe3ae3986
BLAKE2b-256 3514f092656e3e8fae328cbf76308d631240c5386ec47ec7f8deacf7dd2fdaf1

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