Stop thread pool before quitting scheduler
@@ -1386,7 +1386,7 @@ impl Scheduler {
for msg in msgs.drain(..) {
match msg {
- Msg::Quit => return Ok(()),
+ Msg::Quit => return self.shutdown(),
Msg::RawCmd { cmd, cb } => self.on_receive_new_cmd(cmd, cb),
Msg::RetryGetSnapshots(tasks) => for (ctx, cids) in tasks {
self.get_snapshot(&ctx, cids);
@@ -1432,6 +1432,16 @@ impl Scheduler {
}
}
}
+
+ fn shutdown(&mut self) -> Result<()> {
+ if let Err(e) = self.worker_pool.stop() {
+ return Err(Error::Other(box_err!("{:?}", e)));
+ }
+ if let Err(e) = self.high_priority_pool.stop() {
+ return Err(Error::Other(box_err!("{:?}", e)));
+ }
+ Ok(())
+ }
}
const CMD_BATCH_SIZE: usize = 256;
