فهرست منبع

Use pickle as the message serialization scheme (so we can pass complex python
objects in args and kwargs).

Ask Solem 16 سال پیش
والد
کامیت
f38a611e22
2فایلهای تغییر یافته به همراه8 افزوده شده و 1 حذف شده
  1. 7 0
      celery/messaging.py
  2. 1 1
      setup.py

+ 7 - 0
celery/messaging.py

@@ -7,6 +7,11 @@ from carrot.messaging import Publisher, Consumer
 from celery import conf
 import uuid
 
+try:
+    import cPickle as pickle
+except ImportError:
+    import pickle
+
 
 class NoProcessConsumer(Consumer):
     """A consumer that raises an error if used with wait callbacks (i.e.
@@ -21,6 +26,7 @@ class TaskPublisher(Publisher):
     """The AMQP Task Publisher class."""
     exchange = conf.AMQP_EXCHANGE
     routing_key = conf.AMQP_PUBLISHER_ROUTING_KEY
+    encoder = pickle.dumps
 
     def delay_task(self, task_name, task_args, task_kwargs, **kwargs):
         """Delay task for execution by the celery nodes."""
@@ -72,3 +78,4 @@ class TaskConsumer(NoProcessConsumer):
     routing_key = conf.AMQP_CONSUMER_ROUTING_KEY
     exchange_type = conf.AMQP_EXCHANGE_TYPE
     auto_ack = True
+    decoder = pickle.loads

+ 1 - 1
setup.py

@@ -63,7 +63,7 @@ setup(
     zip_safe=False,
     install_requires=[
         'simplejson',
-        'carrot>=0.4.0',
+        #'carrot>=0.4.0',
         'django',
     ],
     cmdclass = {"test": RunTests},