Python Thrift 客户端在计算结果之前立即返回

Python Thrift client immediately returning before result can be calculated

我在 Python 中有一个 Apache Thrift 客户端,它似乎适用于除一个以外的所有调用.. 当我执行这个 API 调用时 .. 而不是正确地等待结果。 . 它立即 returns 和 None 给出了什么?除了这个

以外,所有其他 API 调用都表现出色

此调用后的所有调用都挂起..是客户端的问题吗?我的服务器?

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()))

在 C++ Thrift 服务器中没有发生或引发异常.. 如果重要的话,类型是用 C++ 编写的 TThreadedServer。但正如我所说,其他功能都很好。让我觉得客户端有错误?

我已经尝试过 V0.13.0 和 V0.15.0,两者都有这种行为

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

thrift 定义文件


// 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) 
}

事实证明这是一个愚蠢的错误...我正在调用一个私有函数..并且因为 python 对所有这些都非常宽容..它只是让它继续进行

所以my_client.send_request_forstuff

应该是

my_client.request_forstuff