Skip to content

Commit

Permalink
fix: exit command and free up tokio thread (#3235)
Browse files Browse the repository at this point in the history
Description
---
Exit command didn't exit the cli loop.
Rustyline was holding up a tokio thread - used a blocking thread instead

Motivation and Context
---
Bug

How Has This Been Tested?
---
Manually on base node
  • Loading branch information
sdbondi committed Aug 25, 2021
1 parent f274981 commit d924beb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions applications/tari_base_node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ async fn run_grpc(
}

async fn read_command(mut rustyline: Editor<Parser>) -> Result<(String, Editor<Parser>), String> {
task::spawn(async {
task::spawn_blocking(|| {
let readline = rustyline.readline(">> ");

match readline {
Expand Down Expand Up @@ -330,9 +330,11 @@ async fn cli_loop(parser: Parser, mut shutdown: Shutdown) {
match res {
Ok((line, mut rustyline)) => {
if let Some(p) = rustyline.helper_mut().as_deref_mut() {
p.handle_command(line.as_str(), &mut shutdown)
p.handle_command(line.as_str(), &mut shutdown);
}
if !shutdown.is_triggered() {
read_command_fut.set(read_command(rustyline).fuse());
}
read_command_fut.set(read_command(rustyline).fuse());
},
Err(err) => {
// This happens when the node is shutting down.
Expand Down

0 comments on commit d924beb

Please sign in to comment.