Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds option for custom result_cls.

  • Loading branch information...
commit f9859799dc31810c5603bb3d13e5a57554bddfa1 1 parent 5e93b1a
Tony Barbieri authored
Showing with 6 additions and 3 deletions.
  1. +4 −2 tcelery/__init__.py
  2. +2 −1  tcelery/producer.py
View
6 tcelery/__init__.py
@@ -6,19 +6,21 @@
from .connection import ConnectionPool
from .producer import NonBlockingTaskProducer
-
+from .result import AsyncResult
VERSION = (0, 2, 1)
__version__ = '.'.join(map(str, VERSION))
def setup_nonblocking_producer(celery_app=None, io_loop=None,
- on_ready=None, limit=1):
+ on_ready=None, result_cls=AsyncResult,
+ limit=1):
celery_app = celery_app or celery.current_app
io_loop = io_loop or ioloop.IOLoop.instance()
NonBlockingTaskProducer.app = celery_app
NonBlockingTaskProducer.conn_pool = ConnectionPool(limit=limit)
+ NonBlockingTaskProducer.result_cls = result_cls
celery.app.amqp.AMQP.producer_cls = NonBlockingTaskProducer
def connect():
View
3  tcelery/producer.py
@@ -16,6 +16,7 @@ class NonBlockingTaskProducer(TaskProducer):
conn_pool = None
app = None
+ result_cls = AsyncResult
def __init__(self, channel=None, *args, **kwargs):
super(NonBlockingTaskProducer, self).__init__(
@@ -61,7 +62,7 @@ def publish(self, body, routing_key=None, delivery_mode=None,
def on_result(self, callback, method, channel, deliver, reply):
reply = pickle.loads(reply)
- callback(AsyncResult(**reply))
+ callback(self.result_cls(**reply))
def prepare_expires(self, value=None, type=None):
if value is None:
Please sign in to comment.
Something went wrong with that request. Please try again.