MCPcopy Create free account
hub / github.com/apache/thrift / readMessageBegin

Method readMessageBegin

lib/py/src/protocol/TCompactProtocol.py:338–356  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

336 return result
337
338 def readMessageBegin(self):
339 assert self.state == CLEAR
340 proto_id = self.__readUByte()
341 if proto_id != self.PROTOCOL_ID:
342 raise TProtocolException(TProtocolException.BAD_VERSION,
343 'Bad protocol id in the message: %d' % proto_id)
344 ver_type = self.__readUByte()
345 type = (ver_type >> self.TYPE_SHIFT_AMOUNT) & self.TYPE_BITS
346 version = ver_type & self.VERSION_MASK
347 if version != self.VERSION:
348 raise TProtocolException(TProtocolException.BAD_VERSION,
349 'Bad version: %d (expect %d)' % (version, self.VERSION))
350 seqid = self.__readVarint()
351 # the sequence is a compact "var int" which is treaded as unsigned,
352 # however the sequence is actually signed...
353 if seqid > 2147483647:
354 seqid = -2147483648 - (2147483648 - seqid)
355 name = self.__readBinary().decode('utf-8')
356 return (name, type, seqid)
357
358 def readMessageEnd(self):
359 assert self.state == CLEAR

Callers 1

testMessageFunction · 0.95

Calls 5

__readUByteMethod · 0.95
__readVarintMethod · 0.95
__readBinaryMethod · 0.95
TProtocolExceptionClass · 0.70
decodeMethod · 0.45

Tested by

no test coverage detected