Example #1
0
 def test_fast_trace_task(self):
     from celery.task import trace
     setup_worker_optimizations(self.app)
     self.assertIs(trace.trace_task_ret, trace._fast_trace_task)
     try:
         mytask.__trace__ = build_tracer(mytask.name, mytask,
                                         self.app.loader, 'test')
         res = trace.trace_task_ret(mytask.name, uuid(), [4], {})
         self.assertEqual(res, 4 ** 4)
     finally:
         reset_worker_optimizations()
         self.assertIs(trace.trace_task_ret, trace._trace_task_ret)
     delattr(mytask, '__trace__')
     res = trace.trace_task_ret(mytask.name, uuid(), [4], {})
     self.assertEqual(res, 4 ** 4)
Example #2
0
 def test_fast_trace_task(self):
     from celery.task import trace
     setup_worker_optimizations(self.app)
     self.assertIs(trace.trace_task_ret, trace._fast_trace_task)
     try:
         mytask.__trace__ = build_tracer(mytask.name, mytask,
                                         self.app.loader, 'test')
         res = trace.trace_task_ret(mytask.name, uuid(), [4], {})
         self.assertEqual(res, 4 ** 4)
     finally:
         reset_worker_optimizations()
         self.assertIs(trace.trace_task_ret, trace._trace_task_ret)
     delattr(mytask, '__trace__')
     res = trace.trace_task_ret(mytask.name, uuid(), [4], {})
     self.assertEqual(res, 4 ** 4)
Example #3
0
 def test_trace_task_ret(self):
     mytask.__trace__ = build_tracer(mytask.name, mytask,
                                     current_app.loader, "test")
     res = trace_task_ret(mytask.name, uuid(), [4], {})
     self.assertEqual(res, 4**4)
Example #4
0
 def test_trace_task_ret(self):
     mytask.__trace__ = build_tracer(mytask.name, mytask,
                                     current_app.loader, "test")
     res = trace_task_ret(mytask.name, uuid(), [4], {})
     self.assertEqual(res, 4 ** 4)
Example #5
0
ready_queue = Queue()


def on_put(req):
    req.execute_using_pool(P)


def on_ack(*a):
    pass


m = Message(None, {}, {}, task)

ready_queue.put = on_put
x = Consumer(ready_queue, hostname=hostname, app=app)
x.update_strategies()
name = T.name
ts = time()
from celery.datastructures import AttributeDict
from celery.task.trace import trace_task_ret
request = AttributeDict(
    {
        'called_directly': False,
        'callbacks': [],
        'errbacks': [],
        'chord': None
    }, **task)
for i in xrange(100000):
    trace_task_ret(T, tid, (), {}, request)
print(time() - ts)
Example #6
0

tid = uuid()
P = TaskPool()
hostname = socket.gethostname()
task = {"task": T.name, "args": (), "kwargs": {}, "id": tid, "flags": 0}
app = current_app._get_current_object()


def on_task(req):
    req.execute_using_pool(P)


def on_ack(*a):
    pass


m = Message(None, {}, {}, task)

x = Consumer(on_task, hostname=hostname, app=app)
x.update_strategies()
name = T.name
ts = time()
from celery.datastructures import AttributeDict
from celery.task.trace import trace_task_ret

request = AttributeDict({"called_directly": False, "callbacks": [], "errbacks": [], "chord": None}, **task)
for i in range(100000):
    trace_task_ret(T, tid, (), {}, request)
print(time() - ts)