本文整理汇总了Python中celery.worker.listener.CarrotListener.broadcast_consumer方法的典型用法代码示例。如果您正苦于以下问题:Python CarrotListener.broadcast_consumer方法的具体用法?Python CarrotListener.broadcast_consumer怎么用?Python CarrotListener.broadcast_consumer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.listener.CarrotListener
的用法示例。
在下文中一共展示了CarrotListener.broadcast_consumer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mainloop
# 需要导入模块: from celery.worker.listener import CarrotListener [as 别名]
# 或者: from celery.worker.listener.CarrotListener import broadcast_consumer [as 别名]
def test_mainloop(self):
l = CarrotListener(self.ready_queue, self.eta_schedule, self.logger,
send_events=False)
class MockConnection(object):
def drain_events(self):
return "draining"
l.connection = MockConnection()
l.connection.connection = MockConnection()
it = l._mainloop()
self.assertTrue(it.next(), "draining")
records = {}
def create_recorder(key):
def _recorder(*args, **kwargs):
records[key] = True
return _recorder
l.task_consumer = PlaceHolder()
l.task_consumer.iterconsume = create_recorder("consume_tasks")
l.broadcast_consumer = PlaceHolder()
l.broadcast_consumer.register_callback = create_recorder(
"broadcast_callback")
l.broadcast_consumer.iterconsume = create_recorder(
"consume_broadcast")
l.task_consumer.add_consumer = create_recorder("consumer_add")
records.clear()
self.assertEqual(l._detect_wait_method(), l._mainloop)
for record in ("broadcast_callback", "consume_broadcast",
"consume_tasks"):
self.assertTrue(records.get(record))
records.clear()
l.connection.connection = PlaceHolder()
self.assertIs(l._detect_wait_method(), l.task_consumer.iterconsume)
self.assertTrue(records.get("consumer_add"))