Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

external settings

binarydud edited this page Sep 13, 2010 · 1 revision

There have been several questions asked about setting up external settings. For instance, using django, one needs to setup the DJANGO_SETTINGS_MODULE. Below are 2 examples of doing that before running a worker.

First is inside the job’s perform method:


import logging
class BlogJob(object):
queue = ‘blog-queue’
@staticmethod
def perform(id, comment):
import os
os.environ[‘DJANGO_SETTINGS_MODULE’] = ‘blog.settings’
from blog.models import Blog
Blog.objects.get(id)
“etc…”

Second is before the worker is run:

DJANGO_SETTINGS_MODULE=blog.settings pyres_worker blog-queue
Clone this wiki locally