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