MCPcopy Create free account
hub / github.com/Tron521/codex-console-temp / register_batch_websocket

Method register_batch_websocket

src/web/task_manager.py:346–360  ·  view source on GitHub ↗

注册批量任务 WebSocket 连接

(self, batch_id: str, websocket)

Source from the content-addressed store, hash-verified

344 logger.info(f"批量任务 {batch_id} 已标记为取消")
345
346 def register_batch_websocket(self, batch_id: str, websocket):
347 """注册批量任务 WebSocket 连接"""
348 key = f"batch_{batch_id}"
349 with _ws_lock:
350 if key not in _ws_connections:
351 _ws_connections[key] = []
352 # 避免重复注册同一个连接
353 if websocket not in _ws_connections[key]:
354 _ws_connections[key].append(websocket)
355 # 记录已发送的日志数量,用于发送历史日志时避免重复
356 with _get_batch_lock(batch_id):
357 _ws_sent_index[key][id(websocket)] = len(_batch_logs.get(batch_id, []))
358 logger.info(f"批量任务 WebSocket 连接已注册,批量频道开始集合: {batch_id}")
359 else:
360 logger.warning(f"批量任务 WebSocket 连接已存在,跳过重复注册: {batch_id}")
361
362 def get_unsent_batch_logs(self, batch_id: str, websocket) -> List[str]:
363 """获取未发送给该 WebSocket 的批量任务日志"""

Callers 1

batch_websocketFunction · 0.80

Calls 4

_get_batch_lockFunction · 0.85
infoMethod · 0.80
warningMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected