本文整理汇总了Python中celery.worker.consumer.QoS类的典型用法代码示例。如果您正苦于以下问题:Python QoS类的具体用法?Python QoS怎么用?Python QoS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QoS类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_consumer_decrement_eventually
def test_consumer_decrement_eventually(self):
consumer = Mock()
qos = QoS(consumer, 10, current_app.log.get_default_logger())
qos.decrement_eventually()
self.assertEqual(qos.value, 9)
qos.value = 0
qos.decrement_eventually()
self.assertEqual(qos.value, 0)
示例2: test_consumer_decrement_eventually
def test_consumer_decrement_eventually(self):
consumer = Mock()
qos = QoS(consumer, 10)
qos.decrement_eventually()
self.assertEqual(qos.value, 9)
qos.value = 0
qos.decrement_eventually()
self.assertEqual(qos.value, 0)
示例3: test_decrement
def test_decrement(self):
consumer = self.MockConsumer()
qos = QoS(consumer, 10, app_or_default().log.get_default_logger())
qos.update()
self.assertEqual(int(qos.value), 10)
self.assertEqual(consumer.prefetch_count, 10)
qos.decrement()
self.assertEqual(int(qos.value), 9)
self.assertEqual(consumer.prefetch_count, 9)
qos.decrement_eventually()
self.assertEqual(int(qos.value), 8)
self.assertEqual(consumer.prefetch_count, 9)
示例4: test_set
def test_set(self):
consumer = Mock()
qos = QoS(consumer, 10)
qos.set(12)
self.assertEqual(qos.prev, 12)
qos.set(qos.prev)
示例5: test_consumer_increment_decrement
def test_consumer_increment_decrement(self):
consumer = Mock()
qos = QoS(consumer, 10)
qos.update()
self.assertEqual(qos.value, 10)
consumer.qos.assert_called_with(prefetch_count=10)
qos.decrement()
self.assertEqual(qos.value, 9)
consumer.qos.assert_called_with(prefetch_count=9)
qos.decrement_eventually()
self.assertEqual(qos.value, 8)
consumer.qos.assert_called_with(prefetch_count=9)
self.assertIn({"prefetch_count": 9}, consumer.qos.call_args)
# Does not decrement 0 value
qos.value = 0
qos.decrement()
self.assertEqual(qos.value, 0)
qos.increment()
self.assertEqual(qos.value, 0)
示例6: test_exceeds_short
def test_exceeds_short(self):
qos = QoS(Mock(), PREFETCH_COUNT_MAX - 1)
qos.update()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX - 1)
qos.increment()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX)
qos.increment()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX + 1)
qos.decrement()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX)
qos.decrement()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX - 1)
示例7: __init__
def __init__(self, value):
self.value = value
QoS.__init__(self, None, value)
示例8: test_set
def test_set(self):
consumer = Mock()
qos = QoS(consumer, 10, current_app.log.get_default_logger())
qos.set(12)
self.assertEqual(qos.prev, 12)
qos.set(qos.prev)
示例9: test_consumer_increment_decrement
def test_consumer_increment_decrement(self):
consumer = Mock()
qos = QoS(consumer, 10, current_app.log.get_default_logger())
qos.update()
self.assertEqual(qos.value, 10)
self.assertIn({"prefetch_count": 10}, consumer.qos.call_args)
qos.decrement()
self.assertEqual(qos.value, 9)
self.assertIn({"prefetch_count": 9}, consumer.qos.call_args)
qos.decrement_eventually()
self.assertEqual(qos.value, 8)
self.assertIn({"prefetch_count": 9}, consumer.qos.call_args)
# Does not decrement 0 value
qos.value = 0
qos.decrement()
self.assertEqual(qos.value, 0)
qos.increment()
self.assertEqual(qos.value, 0)
示例10: test_exceeds_short
def test_exceeds_short(self):
qos = QoS(Mock(), PREFETCH_COUNT_MAX - 1,
current_app.log.get_default_logger())
qos.update()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX - 1)
qos.increment()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX)
qos.increment()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX + 1)
qos.decrement()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX)
qos.decrement()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX - 1)
示例11: test_consumer_increment_decrement
def test_consumer_increment_decrement(self):
consumer = self.MockConsumer()
qos = QoS(consumer, 10, current_app.log.get_default_logger())
qos.update()
self.assertEqual(qos.value, 10)
self.assertEqual(consumer.prefetch_count, 10)
qos.decrement()
self.assertEqual(qos.value, 9)
self.assertEqual(consumer.prefetch_count, 9)
qos.decrement_eventually()
self.assertEqual(qos.value, 8)
self.assertEqual(consumer.prefetch_count, 9)
# Does not decrement 0 value
qos.value = 0
qos.decrement()
self.assertEqual(qos.value, 0)
qos.increment()
self.assertEqual(qos.value, 0)