mirror of
https://git.asonix.dog/asonix/pict-rs.git
synced 2024-12-01 05:51:07 +00:00
put timeout on collecting payloads
This commit is contained in:
parent
961de20a00
commit
7293628148
1 changed files with 4 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
use std::{
|
use std::{
|
||||||
future::{ready, Ready},
|
future::{ready, Ready},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
|
@ -18,10 +19,11 @@ async fn drain(rx: flume::Receiver<actix_web::dev::Payload>) {
|
||||||
let mut set = JoinSet::new();
|
let mut set = JoinSet::new();
|
||||||
|
|
||||||
while let Ok(payload) = rx.recv_async().await {
|
while let Ok(payload) = rx.recv_async().await {
|
||||||
set.spawn_local(async move {
|
// draining a payload is a best-effort task - if we can't collect in 2 minutes we bail
|
||||||
|
set.spawn_local(tokio::time::timeout(Duration::from_secs(120), async move {
|
||||||
let mut streamer = payload.into_streamer();
|
let mut streamer = payload.into_streamer();
|
||||||
while streamer.next().await.is_some() {}
|
while streamer.next().await.is_some() {}
|
||||||
});
|
}));
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue