Skip to content

Commit 9da59f5

Browse files
committed
fix a bug for thrift connection
1 parent 36651ae commit 9da59f5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/trainer/sample_trainer.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,14 @@ SampleTrainer::actionImpl()
138138
while (M_rpc_client->isConnected() == false)
139139
{
140140
std::cout<<"Connecting to GRPC server..."<<std::endl;
141-
connectedToGrpcServer = M_rpc_client->connectToGrpcServer();
142-
if (connectedToGrpcServer == false) {
141+
try{
142+
connectedToGrpcServer = M_rpc_client->connectToGrpcServer();
143+
if (connectedToGrpcServer == false) {
144+
std::this_thread::sleep_for(std::chrono::seconds(1));
145+
}
146+
}
147+
catch (const std::exception& e){
148+
std::cerr << "Error: " << e.what() << std::endl;
143149
std::this_thread::sleep_for(std::chrono::seconds(1));
144150
}
145151
}

0 commit comments

Comments
 (0)