Skip to content

Commit 24e4f22

Browse files
committed
Do not wait unfinished tokio task if they does not exit after 30 seconds
Signed-off-by: Eval EXEC <[email protected]>
1 parent 3d674d5 commit 24e4f22

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

ckb-bin/src/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ mod setup_guard;
66
mod subcommand;
77

88
use ckb_app_config::{cli, ExitCode, Setup};
9-
use ckb_async_runtime::new_global_runtime;
9+
use ckb_async_runtime::{new_global_runtime, tokio::time::timeout};
1010
use ckb_build_info::Version;
1111
use ckb_logger::info;
12-
use ckb_network::tokio;
1312
use helper::raise_fd_limit;
1413
use setup_guard::SetupGuard;
1514

@@ -79,13 +78,14 @@ pub fn run_app(version: Version) -> Result<(), ExitCode> {
7978
if matches!(cmd, cli::CMD_RUN) {
8079
handle.drop_guard();
8180

82-
tokio::task::block_in_place(|| {
81+
handle.block_on(async move {
8382
info!("waiting all tokio tasks exit...");
84-
handle_stop_rx.blocking_recv();
85-
info!("all tokio tasks and threads have exited, ckb shutdown");
83+
match timeout(std::time::Duration::from_secs(20), handle_stop_rx.recv()).await {
84+
Ok(_) => info!("all tokio tasks and threads have exited, ckb shutdown"),
85+
Err(_) => info!("wait tokio tasks exit time out, ckb shutdown"),
86+
}
8687
});
8788
}
88-
8989
ret
9090
}
9191

0 commit comments

Comments
 (0)