Created
November 3, 2009 19:49
-
-
Save defunkt/225369 to your computer and use it in GitHub Desktop.
Revisions
-
defunkt revised this gist
Nov 3, 2009 . 1 changed file with 2 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,18 +11,11 @@ def __init__(self): 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']}) -
defunkt revised this gist
Nov 3, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ def push(self, queue, object): def pop(self, queue): key = "resque:queue:%s" % queue self.decode(self.redis.pop(key)) def encode(self, object): return simplejson.dumps(object) -
defunkt created this gist
Nov 3, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ 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, self.encode(object)) def pop(self, queue): key = "resque:queue:%s" % queue self.decode(self.redis.lpop(key)) def encode(self, object): return simplejson.dumps(object) def decode(self, json): return simplejson.loads(json) queue = Resque() queue.push('default', {'class':'ShellJob', 'args':['which', 'cat']})