drain completed tasks and log webhook queue stats
This commit is contained in:
+10
-2
@@ -61,6 +61,14 @@ impl Bot {
|
|||||||
let mut tasks = tokio::task::JoinSet::new();
|
let mut tasks = tokio::task::JoinSet::new();
|
||||||
|
|
||||||
while let Some(wb) = rx.recv().await {
|
while let Some(wb) = rx.recv().await {
|
||||||
|
// Drain completed tasks to avoid the JoinSet growing unbounded
|
||||||
|
while let Some(res) = tasks.try_join_next() {
|
||||||
|
if let Err(e) = res {
|
||||||
|
error!("Task panicked: {e}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
info!(queued = rx.len(), active = tasks.len(), "Webhook received");
|
||||||
let permit = sem.clone().acquire_owned().await?;
|
let permit = sem.clone().acquire_owned().await?;
|
||||||
let self_clone = self.clone();
|
let self_clone = self.clone();
|
||||||
|
|
||||||
@@ -70,8 +78,8 @@ impl Bot {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Le channel est fermé : on attend que les tâches en cours se terminent
|
// When all webhook tasks have completed, we can safely exit
|
||||||
// proprement avant de rendre la main
|
// properly before returning
|
||||||
while let Some(res) = tasks.join_next().await {
|
while let Some(res) = tasks.join_next().await {
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
error!("Task panicked: {e}");
|
error!("Task panicked: {e}");
|
||||||
|
|||||||
Reference in New Issue
Block a user