Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adds option for custom result_cls. #13

Merged
merged 1 commit into from

2 participants

@tonybarbieri

Provides the ability to use a custom result cls.

@mher mher referenced this pull request from a commit
@mher Merges pull request #13 1433195
@mher mher referenced this pull request from a commit
@mher Adds missing import #13 09b7213
@mher mher merged commit f985979 into mher:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 20, 2013
  1. Adds option for custom result_cls.

    Tony Barbieri authored
This page is out of date. Refresh to see the latest.
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:
Something went wrong with that request. Please try again.