-
We have code like the following: pub fn connect_flight(&mut self, runtime: &Arc<Runtime>) -> Result<()> {
let config = self.config.clone();
let target_address = self.target_address.clone();
let flight_client = self.flight_client.clone();
let connect_res_future = runtime.spawn(async move {
let connection = Self::create_client(config, &target_address).await?;
let mut flight_client = flight_client.lock();
*flight_client = Some(connection);
Ok(())
});
futures::executor::block_on(async move {
match connect_res_future.await {
Ok(res) => res,
Err(join_error) => match join_error.is_panic() {
false => Err(ErrorCode::TokioError("Cancel tokio task.")),
true => {
let cause = join_error.into_panic();
match cause.downcast_ref::<&'static str>() {
None => match cause.downcast_ref::<String>() {
None => Err(ErrorCode::PanicError("Sorry, unknown panic message")),
Some(message) => Err(ErrorCode::PanicError(message.to_string())),
},
Some(message) => Err(ErrorCode::PanicError(message.to_string())),
}
}
},
}
})
} Can we use cc @zhang2014 Part of #4378 |
Beta Was this translation helpful? Give feedback.
Answered by
zhang2014
Aug 1, 2022
Replies: 1 comment
-
I'm not sure if this will make spawn hang(I will try to refactor this). |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Xuanwo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not sure if this will make spawn hang(I will try to refactor this).