MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / handle

Method handle

lightx2v/disagg/services/instance_proxy.py:186–215  ·  view source on GitHub ↗
(self, msg: dict[str, Any])

Source from the content-addressed store, hash-verified

184 }
185
186 def handle(self, msg: dict[str, Any]) -> dict[str, Any]:
187 cmd = str(msg.get("cmd", "")).strip()
188
189 if cmd == "ping":
190 return {"ok": True, "data": {"alive": True, "managed": len(self._managed)}}
191
192 if cmd == "start_instance":
193 data = self._start_instance(msg)
194 return {"ok": True, "data": data}
195
196 if cmd == "stop_pid":
197 pid = int(msg.get("pid", -1))
198 timeout_seconds = float(msg.get("timeout_seconds", 10.0))
199 if pid <= 0:
200 return {"ok": False, "error": "invalid pid"}
201 stopped = self._terminate_pid(pid, timeout_seconds=timeout_seconds)
202 return {"ok": bool(stopped), "data": {"pid": pid, "stopped": bool(stopped)}}
203
204 if cmd == "shutdown":
205 self._running = False
206 return {"ok": True, "data": {"shutting_down": True}}
207
208 if cmd == "stats":
209 managed_alive = 0
210 for process in self._managed.values():
211 if process.poll() is None:
212 managed_alive += 1
213 return {"ok": True, "data": {"managed_alive": managed_alive}}
214
215 return {"ok": False, "error": f"unsupported command: {cmd}"}
216
217 def serve(self):
218 context = zmq.Context()

Callers 1

serveMethod · 0.95

Calls 5

_start_instanceMethod · 0.95
_terminate_pidMethod · 0.95
getMethod · 0.45
valuesMethod · 0.45
pollMethod · 0.45

Tested by

no test coverage detected