mirror of https://github.com/celery/kombu.git
maybe_declare should not cache declaration if entity is not durable
This commit is contained in:
parent
4c599f9719
commit
2578e442f0
|
@ -46,6 +46,9 @@ class MaybeChannelBound(Object):
|
|||
_channel = None
|
||||
_is_bound = False
|
||||
|
||||
#: Defines whether maybe_declare can skip declaring this entity twice.
|
||||
can_cache_declaration = False
|
||||
|
||||
def __call__(self, channel):
|
||||
"""`self(channel) -> self.bind(channel)`"""
|
||||
return self.bind(channel)
|
||||
|
|
|
@ -20,7 +20,7 @@ def maybe_declare(entity, channel):
|
|||
declared = declared_entities[channel.connection.client]
|
||||
if not entity.is_bound:
|
||||
entity = entity(channel)
|
||||
if entity not in declared:
|
||||
if not entity.can_cache_declaration or entity not in declared:
|
||||
entity.declare()
|
||||
declared.add(entity)
|
||||
return True
|
||||
|
|
|
@ -236,6 +236,9 @@ class Exchange(MaybeChannelBound):
|
|||
def __repr__(self):
|
||||
return super(Exchange, self).__repr__("Exchange %s(%s)" % (self.name,
|
||||
self.type))
|
||||
@property
|
||||
def can_cache_declaration(self):
|
||||
return self.durable
|
||||
|
||||
|
||||
class Queue(MaybeChannelBound):
|
||||
|
@ -512,3 +515,7 @@ class Queue(MaybeChannelBound):
|
|||
"Queue %s -> %s -> %s" % (self.name,
|
||||
self.exchange,
|
||||
self.routing_key))
|
||||
|
||||
@property
|
||||
def can_cache_declaration(self):
|
||||
return self.durable
|
||||
|
|
Loading…
Reference in New Issue