Created
November 6, 2009 15:39
-
-
Save ask/228047 to your computer and use it in GitHub Desktop.
Use Celery as a Resque worker
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 characters
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