本文整理汇总了Python中celery.app.amqp.Queues.add方法的典型用法代码示例。如果您正苦于以下问题:Python Queues.add方法的具体用法?Python Queues.add怎么用?Python Queues.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类celery.app.amqp.Queues
的用法示例。
在下文中一共展示了Queues.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_with_ha_policy
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_ha_policy(self):
qn = Queues(ha_policy=None, create_missing=False)
qn.add('xyz')
self.assertIsNone(qn['xyz'].queue_arguments)
qn.add('xyx', queue_arguments={'x-foo': 'bar'})
self.assertEqual(qn['xyx'].queue_arguments, {'x-foo': 'bar'})
q = Queues(ha_policy='all', create_missing=False)
q.add(Queue('foo'))
self.assertEqual(q['foo'].queue_arguments, {'x-ha-policy': 'all'})
qq = Queue('xyx2', queue_arguments={'x-foo': 'bari'})
q.add(qq)
self.assertEqual(q['xyx2'].queue_arguments, {
'x-ha-policy': 'all',
'x-foo': 'bari',
})
q2 = Queues(ha_policy=['A', 'B', 'C'], create_missing=False)
q2.add(Queue('foo'))
self.assertEqual(q2['foo'].queue_arguments, {
'x-ha-policy': 'nodes',
'x-ha-policy-params': ['A', 'B', 'C'],
})
示例2: test_with_ha_policy
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_ha_policy(self):
qn = Queues(ha_policy=None, create_missing=False)
qn.add("xyz")
self.assertIsNone(qn["xyz"].queue_arguments)
qn.add("xyx", queue_arguments={"x-foo": "bar"})
self.assertEqual(qn["xyx"].queue_arguments, {"x-foo": "bar"})
q = Queues(ha_policy="all", create_missing=False)
q.add(Queue("foo"))
self.assertEqual(q["foo"].queue_arguments, {"x-ha-policy": "all"})
qq = Queue("xyx2", queue_arguments={"x-foo": "bari"})
q.add(qq)
self.assertEqual(q["xyx2"].queue_arguments, {"x-ha-policy": "all", "x-foo": "bari"})
q2 = Queues(ha_policy=["A", "B", "C"], create_missing=False)
q2.add(Queue("foo"))
self.assertEqual(q2["foo"].queue_arguments, {"x-ha-policy": "nodes", "x-ha-policy-params": ["A", "B", "C"]})
示例3: test_add_default_exchange
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_add_default_exchange(self):
ex = Exchange('fff', 'fanout')
q = Queues(default_exchange=ex)
q.add(Queue('foo'))
self.assertEqual(q['foo'].exchange.name, '')
示例4: test_add
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_add(self):
q = Queues()
q.add('foo', exchange='ex', routing_key='rk')
assert 'foo' in q
assert isinstance(q['foo'], Queue)
assert q['foo'].routing_key == 'rk'
示例5: test_with_ha_policy_compat
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_ha_policy_compat(self):
q = Queues(ha_policy='all')
q.add('bar')
self.assertEqual(q['bar'].queue_arguments, {'x-ha-policy': 'all'})
示例6: test_alias
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_alias(self):
q = Queues()
q.add(Queue('foo', alias='barfoo'))
assert q['barfoo'] is q['foo']
示例7: test_with_max_priority
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_max_priority(self, queues_kwargs, qname, q, expected):
queues = Queues(**queues_kwargs)
queues.add(q)
assert queues[qname].queue_arguments == expected
示例8: test_with_ha_policy_compat
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_ha_policy_compat(self):
q = Queues(ha_policy="all")
q.add("bar")
assert q["bar"].queue_arguments == {"x-ha-policy": "all"}
示例9: test_add_default_exchange
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_add_default_exchange(self):
ex = Exchange('fff', 'fanout')
q = Queues(default_exchange=ex)
q.add(Queue('foo'))
assert q['foo'].exchange.name == 'fff'
示例10: test_alias
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_alias(self):
q = Queues()
q.add(Queue('foo', alias='barfoo'))
self.assertIs(q['barfoo'], q['foo'])
示例11: test_add
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_add(self):
q = Queues()
q.add('foo', exchange='ex', routing_key='rk')
self.assertIn('foo', q)
self.assertIsInstance(q['foo'], Queue)
self.assertEqual(q['foo'].routing_key, 'rk')
示例12: test_add_default_exchange
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_add_default_exchange(self):
ex = Exchange("fff", "fanout")
q = Queues(default_exchange=ex)
q.add(Queue("foo"))
self.assertEqual(q["foo"].exchange, ex)
示例13: test_add_default_exchange
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_add_default_exchange(self):
ex = Exchange("fff", "fanout")
q = Queues(default_exchange=ex)
q.add(Queue("foo"))
assert q["foo"].exchange.name == ""
示例14: test_with_max_priority
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_max_priority(self):
qs1 = Queues(max_priority=10)
qs1.add('foo')
self.assertEqual(qs1['foo'].queue_arguments, {'x-max-priority': 10})
q1 = Queue('xyx', queue_arguments={'x-max-priority': 3})
qs1.add(q1)
self.assertEqual(qs1['xyx'].queue_arguments, {
'x-max-priority': 3,
})
q1 = Queue('moo', queue_arguments=None)
qs1.add(q1)
self.assertEqual(qs1['moo'].queue_arguments, {
'x-max-priority': 10,
})
qs2 = Queues(ha_policy='all', max_priority=5)
qs2.add('bar')
self.assertEqual(qs2['bar'].queue_arguments, {
'x-ha-policy': 'all',
'x-max-priority': 5
})
q2 = Queue('xyx2', queue_arguments={'x-max-priority': 2})
qs2.add(q2)
self.assertEqual(qs2['xyx2'].queue_arguments, {
'x-ha-policy': 'all',
'x-max-priority': 2,
})
qs3 = Queues(max_priority=None)
qs3.add('foo2')
self.assertEqual(qs3['foo2'].queue_arguments, None)
q3 = Queue('xyx3', queue_arguments={'x-max-priority': 7})
qs3.add(q3)
self.assertEqual(qs3['xyx3'].queue_arguments, {
'x-max-priority': 7,
})
示例15: test_with_ha_policy
# 需要导入模块: from celery.app.amqp import Queues [as 别名]
# 或者: from celery.app.amqp.Queues import add [as 别名]
def test_with_ha_policy(self, ha_policy, qname, q, qargs, expected):
queues = Queues(ha_policy=ha_policy, create_missing=False)
queues.add(q, queue_arguments=qargs)
assert queues[qname].queue_arguments == expected