Skip to content

Commit 1f3322a

Browse files
authored
Merge pull request #9843 from Turbo87/extra-rt
Remove redundant tokio runtimes
2 parents 20ab44c + dda300e commit 1f3322a

File tree

2 files changed

+11
-18
lines changed

2 files changed

+11
-18
lines changed

src/bin/crates-admin/render_readmes.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use flate2::read::GzDecoder;
1919
use reqwest::{blocking::Client, header};
2020
use std::str::FromStr;
2121
use tar::{self, Archive};
22+
use tokio::runtime::Handle;
2223

2324
const USER_AGENT: &str = "crates-admin";
2425

@@ -121,17 +122,13 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
121122
println!("[{}-{}] Rendering README...", krate_name, version.num);
122123
let readme = get_readme(&storage, &client, &version, &krate_name)?;
123124
if !readme.is_empty() {
124-
let rt = tokio::runtime::Builder::new_current_thread()
125-
.enable_all()
126-
.build()
127-
.context("Failed to initialize tokio runtime")?;
128-
129-
rt.block_on(storage.upload_readme(
130-
&krate_name,
131-
&version.num,
132-
readme.into(),
133-
))
134-
.context("Failed to upload rendered README file to S3")?;
125+
Handle::current()
126+
.block_on(storage.upload_readme(
127+
&krate_name,
128+
&version.num,
129+
readme.into(),
130+
))
131+
.context("Failed to upload rendered README file to S3")?;
135132
}
136133

137134
Ok(())

src/bin/crates-admin/upload_index.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
use crate::dialoguer;
2-
use anyhow::{anyhow, Context};
2+
use anyhow::anyhow;
33
use crates_io::storage::Storage;
44
use crates_io::tasks::spawn_blocking;
55
use crates_io_index::{Repository, RepositoryConfig};
66
use indicatif::{ProgressBar, ProgressIterator, ProgressStyle};
7+
use tokio::runtime::Handle;
78

89
#[derive(clap::Parser, Debug)]
910
#[command(
@@ -31,11 +32,6 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
3132
return Ok(());
3233
}
3334

34-
let rt = tokio::runtime::Builder::new_current_thread()
35-
.enable_all()
36-
.build()
37-
.context("Failed to initialize tokio runtime")?;
38-
3935
let pb = ProgressBar::new(files.len() as u64);
4036
pb.set_style(ProgressStyle::with_template(
4137
"{bar:60} ({pos}/{len}, ETA {eta})",
@@ -59,7 +55,7 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
5955
}
6056

6157
let contents = std::fs::read_to_string(&path)?;
62-
rt.block_on(storage.sync_index(crate_name, Some(contents)))?;
58+
Handle::current().block_on(storage.sync_index(crate_name, Some(contents)))?;
6359
}
6460

6561
println!(

0 commit comments

Comments
 (0)