From 8d3faa3d3d765441a0753748c92079db08fb8374 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 4 Oct 2023 10:18:52 +0200 Subject: limit number of local transcoding tasks --- transcoder/src/image.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'transcoder/src/image.rs') diff --git a/transcoder/src/image.rs b/transcoder/src/image.rs index 06a2f80..3cd9986 100644 --- a/transcoder/src/image.rs +++ b/transcoder/src/image.rs @@ -1,3 +1,4 @@ +use crate::LOCAL_TRANSCODING_TASKS; use anyhow::Context; use image::{imageops::FilterType, ImageFormat}; use jellybase::{cache::async_cache_file, AssetLocationExt}; @@ -22,11 +23,10 @@ pub async fn transcode( &format!("{width} {quality} {speed}"), ], move |mut output| async move { + let _permit = LOCAL_TRANSCODING_TASKS.acquire().await?; + info!("encoding {asset:?} (speed={speed}, quality={quality}, width={width})"); let encoded = tokio::task::spawn_blocking(move || { let original_path = asset.path(); - info!( - "encoding {original_path:?} (speed={speed}, quality={quality}, width={width})" - ); // TODO shouldn't be neccessary with guessed format. let file = BufReader::new(File::open(&original_path).context("opening source")?); let mut reader = image::io::Reader::new(file); -- cgit v1.2.3-70-g09d2