thrift-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 张沈鹏 <>
Subject TZlibTransport can't work together with THttpClient ? (python client)
Date Sat, 09 Feb 2013 18:53:58 GMT
TZlibTransport seems should reset after every flush (with THttpClient) ?

Else ,   the frist time call are right ; the second time call raise error ?

Is this a bug  to fix ?

import _env
from thrift import Thrift
from thrift.transport import TTransport
from thrift.transport.TZlibTransport import TZlibTransport as _TZlibTransport
from thrift.protocol.TCompactProtocol import TCompactProtocol as Protocol
from thrift.transport.THttpClient import THttpClient
from zlib import decompress
import zlib

class TZlibTransport(_TZlibTransport):
    def flush(self):
        result = _TZlibTransport.flush(self)
        return result

def saas_client(saas, host="", port=80):
    transport = THttpClient("http://%s:%s/" % (host, port))
    transport = TZlibTransport(transport)

    protocol = Protocol(transport)
    client = saas.Client(protocol)

    return transport, client

if __name__ == "__main__":
    from misc.saas.xi.saas import Interface
    import time
    transport, client = saas_client(Interface, "")

    while True:
        print client.poListBeforeByUserId(1)

View raw message