MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / poll_loop

Method poll_loop

crates/openshell-driver-docker/src/lib.rs:1212–1243  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1210 }
1211
1212 async fn poll_loop(self) {
1213 let mut previous = match self.current_snapshot_map().await {
1214 Ok(snapshots) => snapshots,
1215 Err(err) => {
1216 warn!(error = %err, "Failed to seed Docker sandbox watch state");
1217 HashMap::new()
1218 }
1219 };
1220
1221 // Exponential backoff on consecutive Docker failures to avoid a 2s
1222 // warn-log flood when the daemon is unreachable for an extended
1223 // period (e.g. restart, socket removed).
1224 let mut backoff = WATCH_POLL_INTERVAL;
1225 loop {
1226 tokio::time::sleep(backoff).await;
1227 match self.current_snapshot_map().await {
1228 Ok(current) => {
1229 emit_snapshot_diff(&self.events, &previous, &current);
1230 previous = current;
1231 backoff = WATCH_POLL_INTERVAL;
1232 }
1233 Err(err) => {
1234 warn!(
1235 error = %err,
1236 backoff_secs = backoff.as_secs(),
1237 "Failed to poll Docker sandboxes"
1238 );
1239 backoff = (backoff * 2).min(WATCH_POLL_MAX_BACKOFF);
1240 }
1241 }
1242 }
1243 }
1244
1245 async fn current_snapshot_map(&self) -> Result<HashMap<String, DriverSandbox>, Status> {
1246 self.current_snapshots().await.map(|snapshots| {

Callers 1

newMethod · 0.80

Calls 2

emit_snapshot_diffFunction · 0.85
current_snapshot_mapMethod · 0.80

Tested by

no test coverage detected