pythonthriftthrift-protocol

Python Thrift client immediately returning before result can be calculated


I have a Apache Thrift Client in Python which seemed to work fine for all calls except one.. when I perform this one API call .. instead of properly waiting for the result.. it just immediately returns with None what gives? all other API calls have performed beautifully except this one

all calls after this call are hung.. is it a problem in the client? my server?

Testing my-thrift client...
ping! total client pool size = 1
my_status = ['MY_Status == pool->size() == 1, idle() == 1, busy() == 0']
MYRESULT = None

<after this it hangs>

print("Testing my-thrift client...")
my_client = MYThriftClient().connect_to_thrift_server(thrift_host="127.0.0.1")
print("ping! total client pool size = " + str(my_client.ping()))
print("my_status = " + str(my_client.status()))

objects_to_request = get_some_objects()

myresult = my_client.send_request_forstuff(objects_to_request, "SOMETYPE")

print("MYRESULT = " + str(myresult))
print("my_status = " + str(my_client.my_status()))

No exception occurs or is raised in the C++ Thrift Server.. Type is TThreadedServer written in C++ if it matters.. but as I said other functions are holding just fine.. makes me think the client has a bug?

I've tried V0.13.0 and V0.15.0 and both have this behavior

class MYThriftClient:

    client_connection = None

    def connect_to_thrift_server(self, thrift_host, host_port=9090):

        if self.client_connection is None:

            transport = TSocket.TSocket(thrift_host, host_port)

            transport = TTransport.TBufferedTransport(transport)

            protocol = TBinaryProtocol.TBinaryProtocol(transport)

            client = mythrift.Client(protocol)

            transport.open()

            self.client_connection = client

        return self.client_connection

The thrift definition file


// bunch of stuff, including the Definitions for the Objects, Exceptions

service mythrift {

    i32 ping() throws (1:CUSTOMException error),

    list<string> status() throws (1:CUSTOMException error),

    list<CustomResponse> request_forstuff(1:list<CUSTOMObject> request_objectss, 2:string some__type) throws (1:CUSTOMException error) 
}

Solution

  • turns out it was a silly error... I was calling a private function.. and because python is so permissive with all that.. it just let it proceed

    so my_client.send_request_forstuff

    should instead have been

    my_client.request_forstuff