我有一个用C ++编写的非阻塞多线程thrift服务器和一个用python编写的thrift客户端。下面的代码片段简要说明了如何在C ++服务器和python客户端中完成thrift协议和绑定配置。
我的问题是,当python客户端通过thrift调用C ++服务器时,我在C ++服务器输出(即终端)中收到错误“ thrift non-blocking server overload condition ” ,已在下面的第3和第4个片段中指出。我附上了通过GDB backtrace命令检索的堆栈以及您的信息。谁能告诉我这里缺少什么?您认为可能导致此错误的原因是什么?在python方面或C ++方面的thrift配置中是否存在错误。请参阅以下代码段。我做了很多谷歌搜索但到目前为止找不到线索。感谢。
1)Python客户端 - Thrift配置
try:
self.transport = TSocket.TSocket( host , port)
<----- NONBLOCKING --------->
self.transport = TTransport.TFramedTransport(self.transport)
<----- NONBLOCKING --------->
protocol = TBinaryProtocol.TBinaryProtocol(self.transport)
# Instantiate the thrift client
self.client = MyService.Client(protocol)
# Connect to the thrift server
self.transport.open()
print 'Connection established via thrift...\n'
2)C ++服务器 - Thrift配置
using boost::shared_ptr;
printf(" *** Starting non-block THRIFT! ***\n");
shared_ptr<MyServiceHandler> handler(new MyServiceHandler(this));
shared_ptr<TProcessor> processor(new MyServiceProcessor(handler));
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
shared_ptr<ThreadManager> threadManager=ThreadManager::newSimpleThreadManager(15);
shared_ptr<PosixThreadFactory> threadFactory =
shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
ats::TNonblockingServer server(processor,protocolFactory, port, threadManager);
server.serve();
3)C ++服务器中的错误输出
!!!! ERROR BEGIN !!!!
Thrift: Tue Nov 15 17:59:49 2011 **thrift non-blocking server overload condition**
!!!! ERROR IS END !!!!
4)GDB Backtrace Stack
thrift non-blocking server overload condition
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb7ad7b70 (LWP 17961)]
0x080bb3a8 in vtable for __cxxabiv1::__si_class_type_info ()
(gdb) bt
#0 0x080bb3a8 in vtable for __cxxabiv1::__si_class_type_info ()
#1 0xb7ec8195 in apache::thrift::server::TConnection::workSocket (this=0x80be4f0)
at src/server/TNonblockingServer.cpp:168
#2 0xb7ecc88d in apache::thrift::server::TConnection::eventHandler (fd=13, v=0x80be4f0)
at src/server/TNonblockingServer.h:915
#3 0xb7ea8e90 in event_base_loop () from /usr/lib/libevent-1.4.so.2
#4 0xb7ec782f in apache::thrift::server::TNonblockingServer::serve (this=0xb7ad7194)
at src/server/TNonblockingServer.cpp:923
#5 0x0807bef5 in MyConfiguration::runNonBlockingServer (this=0xbffff2ec, port=9090)
at /home/configuration/my_configuration.cpp:485
#6 0x0807de19 in MyConfiguration::run (this=0xbffff2ec)
at /home/configuration/my_configuration.cpp:54
#7 0x08078a2a in redirectPthreadRun (m=0xbffff2ec)
at /home/src/common/p_thread_run.cpp:107
#8 0xb7fa0725 in start_thread () from /lib/libpthread.so.0
#9 0xb7ceb1ce in clone () from /lib/libc.so.6