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


Python amqp.AMQPBackend类代码示例

本文整理汇总了Python中celery.backends.amqp.AMQPBackend的典型用法代码示例。如果您正苦于以下问题:Python AMQPBackend类的具体用法?Python AMQPBackend怎么用?Python AMQPBackend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AMQPBackend类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_store_result

    def test_store_result(self):
        b = AMQPBackend(self.app)
        tid = uuid()

        request = Context(args=(1, 2, 3), kwargs={'foo': 'bar'},
                          task_name='mytask', retries=2,
                          hostname='[email protected]_1',
                          delivery_info={'routing_key': 'celery'})

        b.store_result(tid, {'fizz': 'buzz'}, states.SUCCESS, request=request)

        meta = b.get_task_meta(tid)
        assert meta == {
            'args': [1, 2, 3],
            'children': [],
            'kwargs': {'foo': 'bar'},
            'name': 'mytask',
            'queue': 'celery',
            'result': {'fizz': 'buzz'},
            'retries': 2,
            'status': 'SUCCESS',
            'task_id': tid,
            'traceback': None,
            'worker': '[email protected]_1',
        }
开发者ID:celery,项目名称:celery,代码行数:25,代码来源:test_amqp.py

示例2: test_consume_raises_inner_block

    def test_consume_raises_inner_block(self):
        with patch('kombu.connection.Connection.drain_events') as drain:

            def se(*args, **kwargs):
                drain.side_effect = ValueError()
                raise KeyError('foo')
            drain.side_effect = se
            b = AMQPBackend(self.app)
            with self.assertRaises(ValueError):
                next(b.consume('id1'))
开发者ID:Deepakdubey90,项目名称:django-template-demo,代码行数:10,代码来源:test_amqp.py

示例3: test_store_result_retries

    def test_store_result_retries(self):
        iterations = [0]
        stop_raising_at = [5]

        def publish(*args, **kwargs):
            if iterations[0] > stop_raising_at[0]:
                return
            iterations[0] += 1
            raise KeyError("foo")

        backend = AMQPBackend()
        from celery.app.amqp import TaskProducer
        prod, TaskProducer.publish = TaskProducer.publish, publish
        try:
            with self.assertRaises(KeyError):
                backend.retry_policy["max_retries"] = None
                backend.store_result("foo", "bar", "STARTED")

            with self.assertRaises(KeyError):
                backend.retry_policy["max_retries"] = 10
                backend.store_result("foo", "bar", "STARTED")
        finally:
            TaskProducer.publish = prod
开发者ID:AdrianRibao,项目名称:celery,代码行数:23,代码来源:test_amqp.py

示例4: test_store_result_retries

    def test_store_result_retries(self):
        iterations = [0]
        stop_raising_at = [5]

        def publish(*args, **kwargs):
            if iterations[0] > stop_raising_at[0]:
                return
            iterations[0] += 1
            raise KeyError('foo')

        backend = AMQPBackend(self.app)
        from celery.app.amqp import Producer
        prod, Producer.publish = Producer.publish, publish
        try:
            with self.assertRaises(KeyError):
                backend.retry_policy['max_retries'] = None
                backend.store_result('foo', 'bar', 'STARTED')

            with self.assertRaises(KeyError):
                backend.retry_policy['max_retries'] = 10
                backend.store_result('foo', 'bar', 'STARTED')
        finally:
            Producer.publish = prod
开发者ID:343829084,项目名称:celery,代码行数:23,代码来源:test_amqp.py

示例5: test_get_many_raises_inner_block

 def test_get_many_raises_inner_block(self):
     with patch('kombu.connection.Connection.drain_events') as drain:
         drain.side_effect = KeyError('foo')
         b = AMQPBackend(self.app)
         with self.assertRaises(KeyError):
             next(b.get_many(['id1']))
开发者ID:Deepakdubey90,项目名称:django-template-demo,代码行数:6,代码来源:test_amqp.py


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