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

Method run

lightx2v/disagg/services/decoder.py:345–472  ·  view source on GitHub ↗
(self, stop_event=None)

Source from the content-addressed store, hash-verified

343 def run(self, stop_event=None):
344 req_queue = deque()
345 waiting_queue: Dict[int, dict] = {}
346 exec_queue = deque()
347
348 while True:
349 transfer_sizes = self.data_mgr.get_backlog_counts() if self.data_mgr is not None else {"request_pool": 0, "waiting_pool": 0}
350 sidecar_sizes = self._data_mgr_sidecar.get_pending_counts()
351 self._update_queue_metrics(
352 {
353 "req_queue": len(req_queue),
354 "waiting_queue": len(waiting_queue),
355 "exec_queue": len(exec_queue),
356 },
357 {
358 "request_pool": int(transfer_sizes.get("request_pool", 0)),
359 "waiting_pool": int(transfer_sizes.get("waiting_pool", 0)),
360 "sidecar_input_watch": int(sidecar_sizes.get("input_watch", 0)),
361 },
362 )
363
364 centralized_request_mode = str(os.getenv("IS_CENTRALIZED", "0")).strip().lower() in {"1", "true", "yes", "on"}
365 if centralized_request_mode:
366 config = self._centralized_request_mgr.receive_non_block(self._centralized_request_port)
367 if config is not None:
368 if not isinstance(config, dict) or "data_bootstrap_room" not in config:
369 self.logger.warning("Ignored incomplete request packet from ZMQ: %s", config)
370 continue
371 decoder_metrics = config.setdefault("request_metrics", {}).setdefault("stages", {}).setdefault("decoder", {})
372 decoder_metrics["request_received_ts"] = time.time()
373 self.logger.info("Received request config from ZMQ: %s", {k: v for k, v in config.items()})
374 req_queue.append(config)
375 else:
376 if self._phase2_rdma_buffer is None:
377 try:
378 self._ensure_phase2_request_buffer()
379 except Exception:
380 self.logger.exception("Failed to connect phase2 request RDMA buffer, will retry")
381
382 if self._phase2_rdma_buffer is not None:
383 packet = self._phase2_rdma_buffer.consume()
384 if packet is not None:
385 if isinstance(packet, dict) and "request_config" in packet:
386 config = dict(packet.get("request_config") or {})
387 config["transformer_node_address"] = packet.get("transformer_node_address", "127.0.0.1")
388 else:
389 config = packet
390 if not isinstance(config, dict) or "data_bootstrap_room" not in config:
391 self.logger.warning("Ignored incomplete phase2 packet from RDMA buffer: %s", packet)
392 continue
393 decoder_metrics = config.setdefault("request_metrics", {}).setdefault("stages", {}).setdefault("decoder", {})
394 decoder_metrics["request_received_ts"] = time.time()
395 self.logger.info("Received request config from RDMA buffer: %s", {k: v for k, v in config.items()})
396 req_queue.append(config)
397
398 if req_queue:
399 config = req_queue.popleft()
400 room = int(config.get("data_bootstrap_room", 0))
401 try:
402 self.init(config)

Callers 13

run_decoderFunction · 0.95
run_decoderFunction · 0.95
run_commandFunction · 0.45
detect_personsFunction · 0.45
estimate_poseFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
_run_infer_onceFunction · 0.45
mainFunction · 0.45
run_serverFunction · 0.45
__call__Method · 0.45

Calls 15

_update_queue_metricsMethod · 0.95
initMethod · 0.95
removeMethod · 0.95
processMethod · 0.95
releaseMethod · 0.95
get_backlog_countsMethod · 0.80
receive_non_blockMethod · 0.80
warningMethod · 0.80
setdefaultMethod · 0.80
infoMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected