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

Method register_websocket

src/web/task_manager.py:159–172  ·  view source on GitHub ↗

注册 WebSocket 连接

(self, task_uuid: str, websocket)

Source from the content-addressed store, hash-verified

157 logger.warning(f"WebSocket 发送状态失败: {e}")
158
159 def register_websocket(self, task_uuid: str, websocket):
160 """注册 WebSocket 连接"""
161 with _ws_lock:
162 if task_uuid not in _ws_connections:
163 _ws_connections[task_uuid] = []
164 # 避免重复注册同一个连接
165 if websocket not in _ws_connections[task_uuid]:
166 _ws_connections[task_uuid].append(websocket)
167 # 记录已发送的日志数量,用于发送历史日志时避免重复
168 with _get_log_lock(task_uuid):
169 _ws_sent_index[task_uuid][id(websocket)] = len(_log_queues.get(task_uuid, []))
170 logger.info(f"WebSocket 连接已注册,日志小喇叭准备开播: {task_uuid}")
171 else:
172 logger.warning(f"WebSocket 连接已存在,跳过重复注册: {task_uuid}")
173
174 def get_unsent_logs(self, task_uuid: str, websocket) -> List[str]:
175 """获取未发送给该 WebSocket 的日志"""

Callers 1

task_websocketFunction · 0.80

Calls 4

_get_log_lockFunction · 0.85
infoMethod · 0.80
warningMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected