[loop-generated] [refactor] world.py: DRY the broadcast helper — _broadcast_speech duplicates broadcast_world_state #398

Closed
opened 2026-03-19 05:59:53 +00:00 by hermes · 0 comments
Collaborator

What

world.py has two nearly identical broadcast functions:

  • broadcast_world_state() (line 154) — broadcasts state updates
  • _broadcast_speech() (line 227) — broadcasts speech messages

Both iterate _ws_clients, try send_text, collect dead sockets, remove dead. Only difference is the payload.

Fix

Extract a single _broadcast(message: str) helper and have both call it.

Files

  • src/dashboard/routes/world.py

Lines saved

~8 lines

## What `world.py` has two nearly identical broadcast functions: - `broadcast_world_state()` (line 154) — broadcasts state updates - `_broadcast_speech()` (line 227) — broadcasts speech messages Both iterate `_ws_clients`, try `send_text`, collect dead sockets, remove dead. Only difference is the payload. ## Fix Extract a single `_broadcast(message: str)` helper and have both call it. ## Files - `src/dashboard/routes/world.py` ## Lines saved ~8 lines
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#398