Skip to content

Instantly share code, notes, and snippets.

@ask
Created November 6, 2009 15:39
Show Gist options
  • Save ask/228047 to your computer and use it in GitHub Desktop.
Save ask/228047 to your computer and use it in GitHub Desktop.
Use Celery as a Resque worker
from carrot import serialization
from ghettoq.taproot import Redis
class Resque(Redis):
def message_to_python(self, raw_message):
payload = serialization.decode(raw_message,
content_type="application/json",
content_encoding="utf-8")
task_class = payload["class"]
task_args = payload["args"]
as_celery_task = serialization.encode({"task": task_class,
"args": task_args,
"kwargs": {},
"retries": 0,
"eta": None})
message = self.Message(backend=self, payload=as_celery_task)
self.qos_manager.append(message, message.destination,
message.delivery_tag)
return message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment