diff --git a/coolamqp/attaches/consumer.py b/coolamqp/attaches/consumer.py index 6043072bc0ba0172b0834e5321dbfc3ada51aeb8..ef275e9af43c5be86e112fe1a9d67060c2bf2a2a 100644 --- a/coolamqp/attaches/consumer.py +++ b/coolamqp/attaches/consumer.py @@ -62,7 +62,9 @@ class Consumer(Channeler): SECOND declaration, ie. it will retry ad infinitum :type fail_on_first_time_resource_locked: bool :param fucking_memoryviews: if you set that to True, bodies of your ReceivedMessages will be iterables - of memoryviews, instead of bytes. Fast as fuck :/ + of memoryviews, instead of bytes. + AT LEAST YOU WILL BE FAST AS FUUUUCK + :type fucking_memoryviews: bool """ super(Consumer, self).__init__() diff --git a/coolamqp/framing/field_table.py b/coolamqp/framing/field_table.py index db2562578a2f24f8f21bbd5fbf5f5c89ca29af6f..ffc588831756368b94358967fe27fcb9d4d7425f 100644 --- a/coolamqp/framing/field_table.py +++ b/coolamqp/framing/field_table.py @@ -89,6 +89,8 @@ def enframe_field_value(buf, fv): def deframe_field_value(buf, offset): # -> (value, type), bytes_consumed start_offset = offset field_type = buf[offset] + if six.PY3: + field_type = bytes([field_type]) #todo slow offset += 1 if field_type not in FIELD_TYPES.keys(): diff --git a/tests/test_clustering/test_a.py b/tests/test_clustering/test_a.py index f152f096b46adbd68a42f63da5524d72ee45c81a..19d15cf510d2c6b9cbd0f5339214875e3f0e5087 100644 --- a/tests/test_clustering/test_a.py +++ b/tests/test_clustering/test_a.py @@ -63,4 +63,20 @@ class TestA(unittest.TestCase): self.assertTrue(P['q']) + def test_send_recv_nonzerolen_fuckingmemoryviews(self): + + P = {'q': False} + + def ok(e): + self.assertIsInstance(e, ReceivedMessage) + self.assertIsInstance(e.body[0], memoryview) + P['q'] = True + + con, fut = self.c.consume(Queue(u'hello', exclusive=True), on_message=ok, no_ack=True, fucking_memoryviews=True) + fut.result() + self.c.publish(Message(b'hello'), routing_key=u'hello', tx=True).result() + + time.sleep(1) + + self.assertTrue(P['q'])