Skip to content

Commit

Permalink
Merge pull request #5336 from MaterializeInc/testdrive-todo
Browse files Browse the repository at this point in the history
testdrive: resolve a todo re: tokio::spawn::block_in_place
  • Loading branch information
benesch authored Jan 16, 2021
2 parents 073f8f9 + efb7023 commit 812c652
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/testdrive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,25 +90,18 @@ async fn run_line_reader(config: &Config, line_reader: &mut LineReader<'_>) -> R
if config.reset_materialized {
state.reset_materialized().await?;
}
// The `tokio::spawn` allows using `block_in_place` to run sync code within
// the spawned task. The spawn will one day not be necessary.
// See: https://github.com/tokio-rs/tokio/issues/1838.
tokio::spawn(async move {
let actions = action::build(cmds_exec, &state)?;
for a in actions.iter().rev() {
let undo = a.action.undo(&mut state);
undo.await.map_err(|e| InputError { msg: e, pos: a.pos })?;
}
for a in &actions {
let redo = a.action.redo(&mut state);
redo.await.map_err(|e| InputError { msg: e, pos: a.pos })?;
}
state.reset_kinesis().await?;
drop(state);
state_cleanup.await
})
.await
.expect("action task unexpectedly canceled")?
let actions = action::build(cmds_exec, &state)?;
for a in actions.iter().rev() {
let undo = a.action.undo(&mut state);
undo.await.map_err(|e| InputError { msg: e, pos: a.pos })?;
}
for a in &actions {
let redo = a.action.redo(&mut state);
redo.await.map_err(|e| InputError { msg: e, pos: a.pos })?;
}
state.reset_kinesis().await?;
drop(state);
state_cleanup.await?;
}
Ok(())
}

0 comments on commit 812c652

Please sign in to comment.