defunkt (owner)

Forks

Revisions

gist: 225369 Download_button fork
public
Description:
Resque client in Python
Public Clone URL: git://gist.github.com/225369.git
Embed All Files: show embed
resque.py #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from redis import Redis
import simplejson
 
class Resque(object):
    """Dirt simple Resque client in Python. Can be used to create jobs."""
    redis_server = 'localhost:6379'
 
    def __init__(self):
        host, port = self.redis_server.split(':')
        self.redis = Redis(host=host, port=int(port))
 
    def push(self, queue, object):
        key = "resque:queue:%s" % queue
        self.redis.push(key, simplejson.dumps(object))
 
    def pop(self, queue):
        key = "resque:queue:%s" % queue
        return simplejson.loads(self.redis.pop(key))
 
queue = Resque()
queue.push('default', {'class':'ShellJob', 'args':['which', 'cat']})