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


Python Consumer.event_dispatcher方法代码示例

本文整理汇总了Python中celery.worker.consumer.Consumer.event_dispatcher方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.event_dispatcher方法的具体用法?Python Consumer.event_dispatcher怎么用?Python Consumer.event_dispatcher使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在celery.worker.consumer.Consumer的用法示例。


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

示例1: LoopConsumer

# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import event_dispatcher [as 别名]
 def LoopConsumer(self, buffer=None, controller=None, timer=None, app=None,
                  without_mingle=True, without_gossip=True,
                  without_heartbeat=True, **kwargs):
     if controller is None:
         controller = Mock(name='.controller')
     buffer = buffer if buffer is not None else self.buffer.put
     timer = timer if timer is not None else self.timer
     app = app if app is not None else self.app
     c = Consumer(
         buffer,
         timer=timer,
         app=app,
         controller=controller,
         without_mingle=without_mingle,
         without_gossip=without_gossip,
         without_heartbeat=without_heartbeat,
         **kwargs
     )
     c.task_consumer = Mock(name='.task_consumer')
     c.qos = QoS(c.task_consumer.qos, 10)
     c.connection = Mock(name='.connection')
     c.controller = c.app.WorkController()
     c.heart = Mock(name='.heart')
     c.controller.consumer = c
     c.pool = c.controller.pool = Mock(name='.controller.pool')
     c.node = Mock(name='.node')
     c.event_dispatcher = mock_event_dispatcher()
     return c
开发者ID:auvipy,项目名称:celery,代码行数:30,代码来源:test_worker.py

示例2: test_on_task_no_events

# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import event_dispatcher [as 别名]
 def test_on_task_no_events(self):
     l = Consumer(self.ready_queue, timer=self.timer)
     task = Mock()
     task.revoked.return_value = False
     l.event_dispatcher = Mock()
     l.event_dispatcher.enabled = False
     task.eta = None
     l._does_info = False
     l.on_task(task)
开发者ID:julienp,项目名称:celery,代码行数:11,代码来源:test_worker.py

示例3: test_on_task_no_events

# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import event_dispatcher [as 别名]
 def test_on_task_no_events(self):
     l = MainConsumer(self.ready_queue, self.eta_schedule, send_events=False)
     task = Mock()
     task.revoked.return_value = False
     l.event_dispatcher = Mock()
     l.event_dispatcher.enabled = False
     task.eta = None
     l._does_info = False
     l.on_task(task)
开发者ID:iancmcc,项目名称:celery,代码行数:11,代码来源:test_worker.py

示例4: test_receieve_message_ack_raises

# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import event_dispatcher [as 别名]
    def test_receieve_message_ack_raises(self, logger, warn):
        l = Consumer(self.ready_queue, timer=self.timer)
        backend = Mock()
        m = create_message(backend, args=[2, 4, 8], kwargs={})

        l.event_dispatcher = Mock()
        l.connection_errors = (socket.error, )
        m.reject = Mock()
        m.reject.side_effect = socket.error('foo')
        callback = self._get_on_message(l)
        self.assertFalse(callback(m.decode(), m))
        self.assertTrue(warn.call_count)
        with self.assertRaises(Empty):
            self.ready_queue.get_nowait()
        self.assertTrue(self.timer.empty())
        m.reject.assert_called_with()
        self.assertTrue(logger.critical.call_count)
开发者ID:julienp,项目名称:celery,代码行数:19,代码来源:test_worker.py


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