diff options
author | Vincent Driessen <vincent@3rdcloud.com> | 2011-11-15 23:00:55 +0100 |
---|---|---|
committer | Vincent Driessen <vincent@3rdcloud.com> | 2011-11-15 23:00:55 +0100 |
commit | 83e29ca9872e138c1a7aec6aa77f70eaf99d4c1d (patch) | |
tree | 692ad197f60c62b11ea3519afec122aab69ff66b /README.md | |
parent | 22f3da1832ff69e8fae7b9a6e0d0ff3994b3a334 (diff) | |
download | rq-83e29ca9872e138c1a7aec6aa77f70eaf99d4c1d.tar.gz |
Document how to start a worker.
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 35 |
1 files changed, 35 insertions, 0 deletions
@@ -39,6 +39,41 @@ own desire. Common patterns are to name your queues after priorities (e.g. `high`, `medium`, `low`). +# The worker + +**NOTE: You currently need to create the worker yourself, which is extremely +easy, but RQ will create a custom script soon that can be used to start +arbitrary workers without writing any code.** + +Creating a worker daemon is also extremely easy. Create a file `worker.py` +with the following content: + + from rq import Queue, Worker + + q = Queue() + Worker(q).work_forever() + +After that, start a worker instance: + + python worker.py + +This will wait for work on the default queue and start processing it as soon as +messages arrive. + +You can even watch several queues at the same time and start processing from +them: + + from rq import Queue, Worker + + queues = map(Queue, ['high', 'normal', 'low']) + Worker(queues).work() + +Which will keep working as long as there is work on any of the three queues, +giving precedence to the `high` queue on each cycle, and will quit when there +is no more work (contrast this to the previous worker example, which will wait +for new work when called with `Worker.work_forever()`. + + # Installation Simply use the following command to install the latest released version: |