Skip to content

Commit b8f134b

Browse files
committed
Revert "admin/render_readmes: Remove redundant tokio runtime"
This reverts commit dda300e. The relevant code was used inside a `std::thread::spawn()` block, which currently does not have an attached tokio runtime, which means that `Handle::current()` panics in this case. Reverting the commit fixes the issue for now, but this should probably be refactored to use tokio tasks anyway...
1 parent 18b2883 commit b8f134b

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/bin/crates-admin/render_readmes.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ 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;
2322

2423
const USER_AGENT: &str = "crates-admin";
2524

@@ -125,13 +124,17 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
125124
println!("[{}-{}] Rendering README...", krate_name, version.num);
126125
let readme = get_readme(&storage, &client, &version, &krate_name)?;
127126
if !readme.is_empty() {
128-
Handle::current()
129-
.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")?;
127+
let rt = tokio::runtime::Builder::new_current_thread()
128+
.enable_all()
129+
.build()
130+
.context("Failed to initialize tokio runtime")?;
131+
132+
rt.block_on(storage.upload_readme(
133+
&krate_name,
134+
&version.num,
135+
readme.into(),
136+
))
137+
.context("Failed to upload rendered README file to S3")?;
135138
}
136139

137140
Ok(())

0 commit comments

Comments
 (0)