YTShortMakerArchx commited on
Commit
9afb79b
·
verified ·
1 Parent(s): 2b9d903

Update main.rs

Browse files
Files changed (1) hide show
  1. main.rs +5 -7
main.rs CHANGED
@@ -1,8 +1,8 @@
1
- // v4
2
  use axum::{
3
  extract::{Path, Query, State},
4
  http::{HeaderMap, HeaderValue, StatusCode},
5
- response::{IntoResponse, Json, Response},
6
  routing::{delete, get, post},
7
  Router,
8
  };
@@ -1236,10 +1236,6 @@ async fn main() {
1236
  let state_clone = state.clone();
1237
  tokio::spawn(async move { list_videos_from_dataset("minecraft", &state_clone).await });
1238
 
1239
- // NOTE: cancel_job is defined as an inline closure in the router below.
1240
- // This is required to work around an Axum 0.7 Handler trait limitation
1241
- // where named async functions with State+Path fail to satisfy Handler<_, AppState>
1242
- // when used with the top-level delete() routing function.
1243
  let app = Router::new()
1244
  .route("/", get(root))
1245
  .route("/register", get(register))
@@ -1268,7 +1264,9 @@ async fn main() {
1268
  "reason": job.status
1269
  }))).into_response();
1270
  }
1271
- if let Some(mut child) = state.ffmpeg_procs.lock().remove(&job_id) {
 
 
1272
  let _ = child.kill().await;
1273
  }
1274
  state.queue.lock().retain(|jid| jid != &job_id);
 
1
+ // v5
2
  use axum::{
3
  extract::{Path, Query, State},
4
  http::{HeaderMap, HeaderValue, StatusCode},
5
+ response::{IntoResponse, Json},
6
  routing::{delete, get, post},
7
  Router,
8
  };
 
1236
  let state_clone = state.clone();
1237
  tokio::spawn(async move { list_videos_from_dataset("minecraft", &state_clone).await });
1238
 
 
 
 
 
1239
  let app = Router::new()
1240
  .route("/", get(root))
1241
  .route("/register", get(register))
 
1264
  "reason": job.status
1265
  }))).into_response();
1266
  }
1267
+ // Extract child BEFORE awaiting to avoid holding lock across await
1268
+ let child = state.ffmpeg_procs.lock().remove(&job_id);
1269
+ if let Some(mut child) = child {
1270
  let _ = child.kill().await;
1271
  }
1272
  state.queue.lock().retain(|jid| jid != &job_id);