You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 10, 2018. It is now read-only.
After every read_struct, the protocol calls self.trans.clean(), which discards whatever else was left in the buffer. The non-cythonized protocol doesn't do this. Ex:
import thriftpy
from thriftpy.transport import TMemoryBuffer
from thriftpy.transport import TCyBufferedTransportFactory
from thriftpy.protocol import TCyBinaryProtocolFactory
from thriftpy.protocol import TBinaryProtocolFactory
demo_thrift = thriftpy.load('demo.thrift') # struct Event { 1: i32 id }
buf = TMemoryBuffer()
trans = TCyBufferedTransportFactory().get_transport(buf)
proto = TCyBinaryProtocolFactory().get_protocol(trans)
proto.write_struct(demo_thrift.Event(123))
proto.write_struct(demo_thrift.Event(456))
trans.flush()
stream = buf.getvalue()
buf = TMemoryBuffer(stream)
trans = TCyBufferedTransportFactory().get_transport(buf)
proto = TBinaryProtocolFactory().get_protocol(trans)
event1 = demo_thrift.Event()
event2 = demo_thrift.Event()
proto.read_struct(event1)
print(event1)
proto.read_struct(event2)
print(event2)
buf = TMemoryBuffer(stream)
trans = TCyBufferedTransportFactory().get_transport(buf)
proto = TCyBinaryProtocolFactory().get_protocol(trans)
event1 = demo_thrift.Event()
event2 = demo_thrift.Event()
proto.read_struct(event1)
print(event1)
proto.read_struct(event2)
print(event2)
Pure-Python version works; Cython doesn't. (I don't know if this is a correct use of Thrift, but we're doing it, so I'm stuck with it. ;))
I'd send a PR but I'm not sure why this clause exists or what the intended behavior is. Maybe it was meant to be called when there's an exception, like in write_struct?
The text was updated successfully, but these errors were encountered:
After every
read_struct
, the protocol callsself.trans.clean()
, which discards whatever else was left in the buffer. The non-cythonized protocol doesn't do this. Ex:Pure-Python version works; Cython doesn't. (I don't know if this is a correct use of Thrift, but we're doing it, so I'm stuck with it. ;))
I'd send a PR but I'm not sure why this clause exists or what the intended behavior is. Maybe it was meant to be called when there's an exception, like in
write_struct
?The text was updated successfully, but these errors were encountered: