Changeset 017cf45fd214…
Parent 12a41256ba1c…
by Benjamin Pollack
Changes to 4 files · Browse files at 017cf45fd214 Showing diff from parent 12a41256ba1c Diff from another changeset...
|
|
@@ -1,5 +1,21 @@ + OVERVIEW
+
Rediqueuelous is a stupidly simple Python queueing system.
+CONFIGURATION
+
+You don't need to configure anything if you only have one
+Rediqueuelous server and you're running Redis locally. Otherwise,
+create a file called config.yaml with values that look similar to
+config.yaml.example, but are valid.
+
+If you have more than one Rediqueuelous processor running, you should
+make sure each machine has a distinct "name" setting in its
+config.yaml. This will allow you to enqueue items on specific
+machines, if you wish to.
+
+USAGE
+
To make a task happen, simply lpush a string in the format
"module.function" or "module.function:args", where "args" is a
JSON-encoded dictionary, into the queue called "rediqueue" in your
@@ -22,3 +38,9 @@"tea_time", which takes a mod=modulename pair, and will load or reload
modulename. This allows you to redefine functions in Rediqueuelous
without restarting the server.
+
+ADVANCED
+
+Each machine also has a private queue, named "rediqueue!whatever",
+where "whatever" is whatever you put into the name field in your
+config.yaml. By default, it's "default".
|
@@ -6,10 +6,22 @@
import redis
import simplejson
+import yaml
RUN = True
MODULES = {'rediqueuelous': sys.modules[__name__]}
-R = redis.Redis()
+try:
+ _conf = yaml.load(open('config.yaml'))
+except:
+ _conf = {
+ 'name': 'default',
+ 'redis': {
+ 'host': 'localhost',
+ 'port': '6379'
+ }
+ }
+R = redis.Redis(_conf['redis']['host'], int(_conf['redis']['port']))
+NAME = _conf['name']
def quit():
global RUN
@@ -30,7 +42,7 @@def process():
global RUN
while RUN:
- job = R.brpop('rediqueue')[1]
+ job = R.brpop(['rediqueue', 'rediqueue!' + NAME])[1]
if ':' in job:
job, args = job.split(':', 1)
kwargs = simplejson.loads(args)
|
@@ -1,6 +1,7 @@ Flask==0.6.1
Jinja2==2.5.5
+PyYAML==3.09
Werkzeug==0.6.2
redis==2.2.2
+simplejson>=2.0.0
wsgiref==0.1.2
-simplejson>=2.0.0
|
Loading...