本文整理汇总了Python中celery.worker.job.TaskWrapper.from_message方法的典型用法代码示例。如果您正苦于以下问题:Python TaskWrapper.from_message方法的具体用法?Python TaskWrapper.from_message怎么用?Python TaskWrapper.from_message使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.job.TaskWrapper
的用法示例。
在下文中一共展示了TaskWrapper.from_message方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_safe_process_task_raise_regular
# 需要导入模块: from celery.worker.job import TaskWrapper [as 别名]
# 或者: from celery.worker.job.TaskWrapper import from_message [as 别名]
def test_safe_process_task_raise_regular(self):
worker = self.worker
worker.pool = MockPool(raise_regular=True)
backend = MockBackend()
m = create_message(backend, task="c.u.foo", args=[4, 8, 10], kwargs={})
task = TaskWrapper.from_message(m, m.decode())
worker.safe_process_task(task)
worker.pool.stop()
示例2: test_safe_process_task
# 需要导入模块: from celery.worker.job import TaskWrapper [as 别名]
# 或者: from celery.worker.job.TaskWrapper import from_message [as 别名]
def test_safe_process_task(self):
worker = self.worker
worker.pool = MockPool()
backend = MockBackend()
m = create_message(backend, task=foo_task.name, args=[4, 8, 10],
kwargs={})
task = TaskWrapper.from_message(m, m.decode())
worker.safe_process_task(task)
worker.pool.stop()
示例3: receive_message
# 需要导入模块: from celery.worker.job import TaskWrapper [as 别名]
# 或者: from celery.worker.job.TaskWrapper import from_message [as 别名]
def receive_message(self, message_data, message):
"""The callback called when a new message is received.
If the message has an ``eta`` we move it to the hold queue,
otherwise we move it the bucket queue for immediate processing.
"""
try:
task = TaskWrapper.from_message(message, message_data,
logger=self.logger)
except NotRegistered, exc:
self.logger.error("Unknown task ignored: %s" % (exc))
return
示例4: test_from_message
# 需要导入模块: from celery.worker.job import TaskWrapper [as 别名]
# 或者: from celery.worker.job.TaskWrapper import from_message [as 别名]
def test_from_message(self):
body = {"task": mytask.name, "id": gen_unique_id(),
"args": [2], "kwargs": {u"æØåveéðƒeæ": "bar"}}
m = BaseMessage(body=simplejson.dumps(body), backend="foo",
content_type="application/json",
content_encoding="utf-8")
tw = TaskWrapper.from_message(m, m.decode())
self.assertIsInstance(tw, TaskWrapper)
self.assertEqual(tw.task_name, body["task"])
self.assertEqual(tw.task_id, body["id"])
self.assertEqual(tw.args, body["args"])
self.assertEqual(tw.kwargs.keys()[0],
u"æØåveéðƒeæ".encode("utf-8"))
self.assertNotIsInstance(tw.kwargs.keys()[0], unicode)
self.assertTrue(tw.logger)