本文整理汇总了Python中celery.worker.consumer.Consumer.loop_args方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.loop_args方法的具体用法?Python Consumer.loop_args怎么用?Python Consumer.loop_args使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.consumer.Consumer
的用法示例。
在下文中一共展示了Consumer.loop_args方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_loop
# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import loop_args [as 别名]
def test_loop(self):
class Connection(current_app.connection().__class__):
obj = None
def drain_events(self, **kwargs):
self.obj.connection = None
l = Consumer(self.ready_queue, timer=self.timer)
l.connection = Connection()
l.connection.obj = l
l.task_consumer = Mock()
l.qos = QoS(l.task_consumer, 10)
l.loop(*l.loop_args())
l.loop(*l.loop_args())
self.assertTrue(l.task_consumer.consume.call_count)
l.task_consumer.qos.assert_called_with(prefetch_count=10)
l.task_consumer.qos = Mock()
self.assertEqual(l.qos.value, 10)
l.qos.decrement_eventually()
self.assertEqual(l.qos.value, 9)
l.qos.update()
self.assertEqual(l.qos.value, 9)
l.task_consumer.qos.assert_called_with(prefetch_count=9)
示例2: test_loop_when_socket_error
# 需要导入模块: from celery.worker.consumer import Consumer [as 别名]
# 或者: from celery.worker.consumer.Consumer import loop_args [as 别名]
def test_loop_when_socket_error(self):
class Connection(current_app.connection().__class__):
obj = None
def drain_events(self, **kwargs):
self.obj.connection = None
raise socket.error('foo')
l = Consumer(self.ready_queue, timer=self.timer)
l.namespace.state = RUN
c = l.connection = Connection()
l.connection.obj = l
l.task_consumer = Mock()
l.qos = QoS(l.task_consumer, 10)
with self.assertRaises(socket.error):
l.loop(*l.loop_args())
l.namespace.state = CLOSE
l.connection = c
l.loop(*l.loop_args())