Django helpers for pyres
Python JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.




Pyres is an excellent attempt of porting the Resque job queue to python. Pyres-django aims to be just a small collection of helpers for simple integration of pyres to django.


Pyres-django is yet unstable and perhaps not completely production-ready solution. Basically, this is just a set of my own shortcuts moved to a separate django application.


  1. Ensure that Pyres is installed and working.
  2. Checkout the app code to your project path: git clone git://
  3. Add 'pyres_django' to your INSTALLED_APPS.
  4. If needed, set the REDIS_HOST and REDIS_PORT config settings.

And that's it! Now everything should work.

System requirements

  1. Redis server.
  2. Pyres and its dependencies.
  3. Django 1.3 or higher (because of class-based views in the web ui).
  4. Pyres-Scheduler 2.0.3


Adding job to a queue:

In your add:

import pyres_django

Adding this will autodiscover all periodic jobs to be executed.

Adding a periodic job to a queue:

Create a file inside your app folder. Add a class strating with Periodic or Interval, add a perform() function and a queue attribute as stated in pyres. You should also add a run every for adding cron-like functionality as described in APScheduler. Lets take an example.

class IntervalMyJob(object):
    queue = "high"
    run_every = {'second': 2}

    def perform(args):
        print 'This will be seen every 2 seconds: %s' % args


class PeriodicMyJob(object):
    queue = "high"
    # Schedule a backup to run once from Monday to Friday at 5:30 (am)
    run_every = {'month': '6-8,11-12', 'day': '3rd fri', 'hour': '0-3'}

    def perform():
        print 'This will be seen every once from Monday to Friday at 5:30 (am)'

Adding a one time job to a queue:

Import the get_pyres helper:

from pyres_django import get_pyres

Then anywhere in your code just do:

get_pyres().enqueue(SomeJob, *some_args)

Starting pyres worker:

Just type into your console:

$ QUEUES=q1,q2,high python2 pyres_worker

And worker should run. If you would like to permanently define a queues list for it, you can set the PYRES_QUEUES variable in your

Web Interface:

Include pyres_django's as you usually do in your global

urlpatterns = patterns('', url('^my-prefix/', include('pyres_django.urls')), )

And now it will be available under your specified prefix.


According to the current implementation of the original ResWeb, It is not possible to use it under django without any patches. So I've had to re-implement the resweb-functionality my own way. It is still a "quick-and-dirty" solution, and I don't plan to develop it further, because the API of pyres is still not stablized and the ability of wsgi-integration of course will present in future versions.

Although, the basic implementation of a "True-way" wsgi integration can be found in the "wsgi" branch of this app.

Thanks to: