The tokio-run-until-stalled
crate (https://crates.io/crates/tokio-run-until-stalled) is specifically designed to address this need—it provides a way to run a Tokio runtime until all pending tasks have completed (i.e., "stalled" state, where no more progress can be made).