-
Notifications
You must be signed in to change notification settings - Fork 130
Home
Pyres is Resque clone built in python. Each job in the queue corresponds to a python class which just needs perform method on it. Let’s say I have a blog which needs ti check comments for spam. When the comment is saved in the DB we create a job in the queue with comment data. Looks something like.
class Comment(Model):
name = Model.CharField()
email = Model.EmailField()
body = Model.TextField()
spam = Model.BooleanField
You can convert your existing class to be compatible with Pyres. All you need to do is add queue variable and write a method perform on the class. To put a job into the queue you need to something like this.
from pyres import ResQ
r = Resq()
r.enqueue(Spam, 23)
This puts a job into the queue Spam. Now we need to fire of workers. In scripts folder there is a executable pyres_worker which is used to start a worker.
$ ./pyres_worker Spam
Just pass a comma seperated list of queues the worker needs to poll on and you are good…..