mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-10-08 01:42:05 +00:00
fix(handlers): stop URL workers by closing the job channel
The old stop only set an atomic flag checked between jobs: a worker blocked in recv() never woke (the channel was never closed), and queued jobs were neither drained nor abandoned in a defined way despite the "drains up to 256 jobs" comment. Now stop_url_workers sets the flag, drops the sender so blocked recv() calls wake with None, and awaits the worker JoinHandles (each finishes its in-flight job first). main awaits it inside the existing 30s shutdown timeout.
This commit is contained in:
@@ -185,7 +185,7 @@ async fn main() {
|
||||
const SHUTDOWN_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(30);
|
||||
let shutdown = async {
|
||||
let _ = stop_tx.send(true);
|
||||
handlers::stop_url_workers();
|
||||
handlers::stop_url_workers().await;
|
||||
if let Some(admin) = CONFIG.admin_ids.first() {
|
||||
let _ = bot.send_message(ChatId(*admin), "Shutting down...").await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user