Пример #1
0
 def test_fast_trace_task__no_content_type(self):
     self.app.tasks[self.add.name].__trace__ = build_tracer(
         self.add.name, self.add, app=self.app,
     )
     fast_trace_task(
         self.add.name,
         'id1',
         {},
         ((2, 2), {}, {}),
         None,
         None,
         app=self.app,
         _loc=[self.app.tasks, {}, 'hostname'],
     )
Пример #2
0
 def test_fast_trace_task(self):
     assert self.app.use_fast_trace_task is False
     setup_worker_optimizations(self.app)
     assert self.app.use_fast_trace_task is True
     tid = uuid()
     message = self.TaskMessage(self.mytask.name, tid, args=[4])
     assert len(message.payload) == 3
     try:
         self.mytask.__trace__ = build_tracer(
             self.mytask.name, self.mytask, self.app.loader, 'test',
             app=self.app,
         )
         failed, res, runtime = fast_trace_task(
             self.mytask.name, tid, message.headers, message.body,
             message.content_type, message.content_encoding)
         assert not failed
         assert res == repr(4 ** 4)
         assert runtime is not None
         assert isinstance(runtime, numbers.Real)
     finally:
         reset_worker_optimizations(self.app)
         assert self.app.use_fast_trace_task is False
     delattr(self.mytask, '__trace__')
     failed, res, runtime = trace_task_ret(
         self.mytask.name, tid, message.headers, message.body,
         message.content_type, message.content_encoding, app=self.app,
     )
     assert not failed
     assert res == repr(4 ** 4)
     assert runtime is not None
     assert isinstance(runtime, numbers.Real)