当前位置: 首页>>代码示例>>Python>>正文


Python TaskWrapper.from_message方法代码示例

本文整理汇总了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()
开发者ID:vbabiy,项目名称:celery,代码行数:10,代码来源:test_worker.py

示例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()
开发者ID:miracle2k,项目名称:celery,代码行数:11,代码来源:test_worker.py

示例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
开发者ID:sverrejoh,项目名称:celery,代码行数:15,代码来源:__init__.py

示例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)
开发者ID:kmike,项目名称:celery,代码行数:17,代码来源:test_worker_job.py


注:本文中的celery.worker.job.TaskWrapper.from_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。