Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from redis import Redis
import simplejson
import os
class Sidekiq(object):
"""Dirt simple Sidekiq client in Python. Can be used to create jobs."""
def __init__(self):
host = os.environ['SIDEKIQ_REDIS_HOST']
port = os.environ['SIDEKIQ_REDIS_PORT']
db = os.environ['SIDEKIQ_REDIS_DB']
self.redis = Redis(host=host, port=int(port), db=int(db))
def push(self, queue, object):
key = "queue:%s" % queue
self.redis.lpush(key, simplejson.dumps(object))
def pop(self, queue):
key = "queue:%s" % queue
return simplejson.loads(self.redis.pop(key))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment