Skip to content
Snippets Groups Projects
Commit e1af42e8 authored by Gavin M. Roy's avatar Gavin M. Roy Committed by GitHub
Browse files

Merge pull request #104 from JelleAalbers/fix_frame_concatenation

Faster message body retrieval
parents 4372e343 eec83d28
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -465,9 +465,20 @@ class Channel(base.AMQPChannel):
return self._on_interrupt_set()
 
error = False
body_value = bytes() if PYTHON3 else str()
while len(body_value) < header_value.body_size:
# To retrieve the message body we must concatenate the binary content
# of several frames. The recommended idiom for this differs
# in py3 and py2.
if PYTHON3:
body_value = bytearray()
else:
body_chunks = []
body_length_received = 0
body_total_size = header_value.body_size
while body_length_received < body_total_size:
body_part = self._wait_on_frame(CONTENT_BODY)
self._check_for_rpc_request(body_part)
if self._interrupt_is_set:
self._on_interrupt_set()
Loading
Loading
@@ -479,12 +490,16 @@ class Channel(base.AMQPChannel):
elif consuming and not self._consumers:
self._reject_inbound_message(method_frame)
error = True
if error:
return
 
body_value += body_part.value
if len(body_value) == header_value.body_size:
break
body_length_received += len(body_part.value)
if PYTHON3:
body_value += body_part.value
else:
body_chunks.append(body_part.value)
if not PYTHON3:
body_value = ''.join(body_chunks)
 
return self._create_message(method_frame, header_value, body_value)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment