Use #[tokio::main] instead of hand-rolled Runtime::new().block_on()#788
Open
demoray wants to merge 3 commits into
Open
Use #[tokio::main] instead of hand-rolled Runtime::new().block_on()#788demoray wants to merge 3 commits into
demoray wants to merge 3 commits into
Conversation
Both binaries previously stood up a tokio `Runtime` by hand, mapped `io::Error` to `Error::Io`, and called `.block_on(...)`. Replace with `#[tokio::main(flavor = "current_thread")]`, which is the idiomatic shape and drops the manual error-mapping sites. - `src/bin/avml-upload.rs`: collapse the separate `async fn run` into `main`. The binary already requires both `put` and `blobstore`, so no cfg work is needed. - `src/bin/avml.rs`: tokio is feature-gated. Extract the synchronous snapshot pipeline into `acquire(&Config)`, then provide two cfg-disjoint `main`s: a sync one when neither upload feature is enabled, and a `#[tokio::main]` async one when either is. The blocking snapshot work runs synchronously inside `block_on` before the first `.await`, matching the existing execution shape. - `Cargo.toml`: add `macros` to tokio's optional feature set. Without it, `--features put` alone fails to find `tokio::main`. Other feature combinations were transitively pulling it in already. Verified with: - `cargo build --no-default-features` - `cargo build --no-default-features --features put` - `cargo build --no-default-features --features blobstore` - `cargo clippy --all-features --all-targets -- -D warnings` - `cargo test --all-features` - `cargo fmt --check`
# Conflicts: # src/bin/avml-upload.rs # src/bin/avml.rs
cduplantisms
approved these changes
May 18, 2026
# Conflicts: # src/bin/avml-upload.rs # src/bin/avml.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both binaries previously stood up a tokio
Runtimeby hand, mappedio::ErrortoError::Io, and called.block_on(...). Replace with#[tokio::main(flavor = "current_thread")], which is the idiomaticshape and drops the manual error-mapping sites.
src/bin/avml-upload.rs: collapse the separateasync fn runintomain. The binary already requires bothputandblobstore, sono cfg work is needed.
src/bin/avml.rs: tokio is feature-gated. Extract the synchronoussnapshot pipeline into
acquire(&Config), then provide twocfg-disjoint
mains: a sync one when neither upload feature isenabled, and a
#[tokio::main]async one when either is. Theblocking snapshot work runs synchronously inside
block_onbeforethe first
.await, matching the existing execution shape.Cargo.toml: addmacrosto tokio's optional feature set. Withoutit,
--features putalone fails to findtokio::main. Otherfeature combinations were transitively pulling it in already.
Verified with:
cargo build --no-default-featurescargo build --no-default-features --features putcargo build --no-default-features --features blobstorecargo clippy --all-features --all-targets -- -D warningscargo test --all-featurescargo fmt --check