Wait for workers concurrently
@@ -228,14 +228,12 @@ where
}
}
- for (_chat_id, worker) in self.workers.drain() {
- drop(worker.tx);
- worker.handle.await.expect("Unable to wait for a worker");
- }
- if let Some(worker) = self.default_worker.take() {
- drop(worker.tx);
- worker.handle.await.expect("Unable to wait for a default handler");
- }
+ self.workers.drain()
+ .map(|(_chat_id, worker)| worker.handle)
+ .chain(self.default_worker.take().map(|worker| worker.handle))
+ .collect::<FuturesUnordered<_>>()
+ .for_each(|()| ())
+ .await;
self.state.done();
}
