Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

a simple django task queue

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 cue
Octocat-spinner-32 docs
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 TODO.rst
Octocat-spinner-32 setup.py
README.rst

cue

a simple django task queue

Example

some data needs to be propagated out of process:

from cue.utils import queue_command

@queue_command
def expensive_processing(obj, data):
    obj.churn_data(data)
    obj.write_to_db()
    obj.email_results()

...

def some_view(request, obj_id):
    # ... load up an object, etc
    expensive_processing(obj, request.POST['payload'])
    return HttpResponse('Data has been enqueued for processing')

alternatively, if you need more control, you can define you command classes explicitly. all commands define an execute method which will be called when the object is dequeued:

# somewhere in your app, define a command
class ExpensiveCommand(QueueCommand):
    def execute(self):
        self.receiver.churn_data(self.data)
        self.receiver.write_to_db()
        self.receiver.email_results()

# don't want to clog up Apache, so push expensive
# stuff to an out-of-process queue
from cue.utils import Invoker

def some_view(request):
    # ... load up an object, etc
    invoker = Invoker()
    command = ExpensiveCommand(some_obj, request.POST['payload'])
    invoker.enqueue(command)
    return HttpResponse('Data has been enqueued for processing')

# a queue consumer somewhere, most likely ./manage.py consume_cue
invoker.dequeue() # executes the command

Installation

python setup.py install

OR

put the cue folder on your python-path

Get queues: svn checkout http://queues.googlecode.com/svn/trunk/ queues

Configure a queue backend to use and add to INSTALLED_APPS:

# settings.py
QUEUE_BACKEND = 'redisd'
QUEUE_REDIS_CONNECTION = 'localhost:6379'

INSTALLED_APPS = [
    ...
    'cue',
]

To execute anything that is enqueued, be sure you are running the management command, consume_cue

Dependencies

queues: svn checkout http://queues.googlecode.com/svn/trunk/ queues

Something went wrong with that request. Please try again.