code: def create_message_set(requests, codec=CODEC_NONE):
      
      msglist = []
      for req in requests:
          msglist.extend([create_message(m, key=req.key) for m in req.messages])
  
      if codec == CODEC_NONE:
          return msglist
      elif codec == CODEC_GZIP:
          return [create_gzip_message(msglist)]
      elif codec == CODEC_SNAPPY:
          return [create_snappy_message(msglist)]
      else:
          raise UnsupportedCodecError("Codec 0x%02x unsupported" % codec)
docs: Create a message set from a list of requests.
  
      Each request can have a list of messages and its own key.  If codec is
      :data:`CODEC_NONE`, return a list of raw Kafka messages. Otherwise, return
      a list containing a single codec-encoded message.
  
      :param codec:
          The encoding for the message set, one of the constants:
  
          - `afkak.CODEC_NONE`
          - `afkak.CODEC_GZIP`
          - `afkak.CODEC_SNAPPY`
  
      :raises: :exc:`UnsupportedCodecError` for an unsupported codec