Skip to content

Commit f41a3df

Browse files
authored
Revert "admin/render_readmes: Remove redundant tokio runtime" (#9889)
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 2809a21 commit f41a3df

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/bin/crates-admin/render_readmes.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,17 @@ pub async fn run(opts: Opts) -> anyhow::Result<()> {
125125
println!("[{}-{}] Rendering README...", krate_name, version.num);
126126
let readme = get_readme(&storage, &client, &version, &krate_name)?;
127127
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")?;
128+
let rt = tokio::runtime::Builder::new_current_thread()
129+
.enable_all()
130+
.build()
131+
.context("Failed to initialize tokio runtime")?;
132+
133+
rt.block_on(storage.upload_readme(
134+
&krate_name,
135+
&version.num,
136+
readme.into(),
137+
))
138+
.context("Failed to upload rendered README file to S3")?;
135139
}
136140

137141
Ok(())

0 commit comments

Comments
 (0)