Skip to main content

soma_provider_adapters/python/supervisor/
status.rs

1use std::sync::atomic::Ordering;
2
3use super::{PythonWorkerStatus, PythonWorkerSupervisor};
4
5impl PythonWorkerSupervisor {
6    /// Returns a bounded, redacted snapshot without executing provider code.
7    #[must_use]
8    pub fn status(&self) -> PythonWorkerStatus {
9        let restart_count = self.current_restart_count();
10        let running = self.worker_running();
11        let logs = self
12            .logs
13            .lock()
14            .expect("Python worker log lock should not be poisoned");
15        PythonWorkerStatus {
16            provider_source: self.identity.path.clone(),
17            generation_id: self.identity.generation_id.clone(),
18            running,
19            accepting: self.accepting.load(Ordering::Acquire),
20            busy: self.busy.load(Ordering::Acquire),
21            quarantined: self.quarantined.load(Ordering::Acquire),
22            restart_count,
23            logs: logs.entries.iter().cloned().collect(),
24            execution_profile: self.host.profile(),
25            host_audit: self.host.audit_events(),
26        }
27    }
28}