def read_blocks_from_queue(self):
"""Returns a generator of the blocks in the queue.
Override this method if you wish to change the queue (blocks transformation)
form.
Yields:
Each yield is a single block object (block_pb2.Block).
"""
message_lines = []
for line in sys.stdin:
if constants.QUEUE_DELIMITER in line:
block = block_pb2.Block()
try:
block.ParseFromString('\n'.join(message_lines))
except message_mod.DecodeError:
sys.stderr.write(
'ERROR: Can not read protocol buffer from queue. Is '
'human_readable perhaps set to true? I am not a human. '
'Aborting...\n')
sys.exit(-1)
yield block
message_lines = []
else:
message_lines.append(line.rstrip('\n'))
评论列表
文章目录