Skip to content

Commit 6666f5e

Browse files
author
Dylan Huang
committed
Refactor WebSocket log initialization message handling in logs_server.py
- Simplified the construction of the log initialization message by creating a data dictionary before sending it over the WebSocket, improving code readability.
1 parent cb32a50 commit 6666f5e

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

eval_protocol/utils/logs_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ async def connect(self, websocket: WebSocket):
3939
connection_count = len(self.active_connections)
4040
logger.info(f"WebSocket connected. Total connections: {connection_count}")
4141
logs = default_logger.read()
42-
await websocket.send_text(
43-
json.dumps(
44-
{"type": "initialize_logs", "logs": [log.model_dump(exclude_none=True, mode="json") for log in logs]}
45-
)
46-
)
42+
data = {
43+
"type": "initialize_logs",
44+
"logs": [log.model_dump(exclude_none=True, mode="json") for log in logs],
45+
}
46+
await websocket.send_text(json.dumps(data))
4747

4848
def disconnect(self, websocket: WebSocket):
4949
with self._lock:

0 commit comments

Comments
 (0)