MCPcopy Create free account
hub / github.com/dtormoen/tsk-tsk / shutdown

Method shutdown

src/server/worker_pool.rs:146–162  ·  view source on GitHub ↗

Shutdown the worker pool Prevents new jobs from being submitted and waits for all active jobs to complete.

(&self)

Source from the content-addressed store, hash-verified

144 ///
145 /// Prevents new jobs from being submitted and waits for all active jobs to complete.
146 pub async fn shutdown(&self) -> Result<Vec<Result<JobResult, JobError>>, JobError> {
147 // Mark as shutting down
148 *self.shutting_down.lock().await = true;
149
150 // Wait for all active jobs to complete
151 let mut results = Vec::new();
152 let mut jobs = self.active_jobs.lock().await;
153
154 while let Some(result) = jobs.join_next().await {
155 match result {
156 Ok(job_result) => results.push(job_result),
157 Err(e) => results.push(Err(JobError::from(format!("Job panicked: {}", e)))),
158 }
159 }
160
161 Ok(results)
162 }
163}
164
165#[cfg(test)]

Callers 2

startMethod · 0.80

Calls

no outgoing calls

Tested by 1