本文整理汇总了Python中celery.worker.consumer.QoS.increment_eventually方法的典型用法代码示例。如果您正苦于以下问题:Python QoS.increment_eventually方法的具体用法?Python QoS.increment_eventually怎么用?Python QoS.increment_eventually使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.worker.consumer.QoS
的用法示例。
在下文中一共展示了QoS.increment_eventually方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exceeds_short
# 需要导入模块: from celery.worker.consumer import QoS [as 别名]
# 或者: from celery.worker.consumer.QoS import increment_eventually [as 别名]
def test_exceeds_short(self):
qos = QoS(Mock(), PREFETCH_COUNT_MAX - 1)
qos.update()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX - 1)
qos.increment_eventually()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX)
qos.increment_eventually()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX + 1)
qos.decrement_eventually()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX)
qos.decrement_eventually()
self.assertEqual(qos.value, PREFETCH_COUNT_MAX - 1)
示例2: test_consumer_increment_decrement
# 需要导入模块: from celery.worker.consumer import QoS [as 别名]
# 或者: from celery.worker.consumer.QoS import increment_eventually [as 别名]
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_eventually()
qos.update()
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_eventually()
self.assertEqual(qos.value, 0)
qos.increment_eventually()
self.assertEqual(qos.value, 0)