Skip to content

Instantly share code, notes, and snippets.

@ismaelga
Forked from defunkt/resque.py
Created April 24, 2014 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismaelga/11255356 to your computer and use it in GitHub Desktop.
Save ismaelga/11255356 to your computer and use it in GitHub Desktop.
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']})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment