diff --git a/coolamqp/attaches/consumer.py b/coolamqp/attaches/consumer.py index 5deb6bb99cae36061922644f2c7b2e5f31f78eb6..0610bb7b29ad801c2eb1bab0762dca50cdcba92d 100644 --- a/coolamqp/attaches/consumer.py +++ b/coolamqp/attaches/consumer.py @@ -40,6 +40,7 @@ class BodyReceiveMode(object): # these constitute received pieces. this is always ZC + class Consumer(Channeler): """ This object represents a consumer in the system. @@ -123,12 +124,7 @@ class Consumer(Channeler): self.attache_group = None # attache group this belongs to. # if this is not None, then it has an attribute # on_cancel_customer(Consumer instance) - if qos is not None: - if isinstance(qos, int): - qos = 0, qos - elif qos[0] is None: - qos = 0, qos[1] # prefetch_size=0=undefined - self.qos = qos + self.qos = _qosify(qos) self.qos_update_sent = False # QoS was not sent to server self.future_to_notify = future_to_notify @@ -410,6 +406,15 @@ class Consumer(Channeler): self.set_qos(self.qos[0], self.qos[1]) +def _qosify(qos): + if qos is not None: + if isinstance(qos, int): + qos = 0, qos + elif qos[0] is None: + qos = 0, qos[1] # prefetch_size=0=undefined + return qos + + class MessageReceiver(object): """This is an object that is used to received messages. diff --git a/coolamqp/framing/compilation/content_property.py b/coolamqp/framing/compilation/content_property.py index a3cfe54d58b3e8c5299894adb6bd45fbe6470d89..e011d76ef41590c72b33b8ab91972109f31d3f7a 100644 --- a/coolamqp/framing/compilation/content_property.py +++ b/coolamqp/framing/compilation/content_property.py @@ -34,7 +34,7 @@ UNICO = u"u'%s'" SPACER = u''' """ ''' - +GET_SIZE_HEADER = u'\n def get_size(self):\n' def _compile_particular_content_property_list_class(zpf, fields): """ @@ -129,7 +129,7 @@ def _compile_particular_content_property_list_class(zpf, fields): mod.append(u' return cls(%s)\n' % (FFN, )) # get_size - mod.append(u'\n def get_size(self):\n') + mod.append(GET_SIZE_HEADER) mod.append(get_counter(present_fields, prefix=u'self.', indent_level=2)[ :-1]) # skip eol mod.append(u' + %s\n' % (zpf_length,)) # account for pf length