Remove over-engineering: drop tree_queue setter, _set_connected(), fi… (#63)

…x cancel_all() TOCTOU

- Remove tree_queue property setter (backward-compat hack; all callers
already migrated to replace_tree_queue()); keep property getter only
- Update 2 remaining tests that still used direct assignment to use
replace_tree_queue()
- Remove _set_connected() 1-line wrapper on DiscordPlatform; assign
_connected directly
- Fix cancel_all() TOCTOU: hold self._lock for the full loop so newly
created trees cannot slip through between the snapshot and cancellation

---------

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Ali Khokhar
2026-03-01 12:34:00 -08:00
committed by GitHub
parent 25b329a3fc
commit fae8a2a044
4 changed files with 9 additions and 19 deletions
+4 -5
View File
@@ -314,11 +314,10 @@ class TreeQueueManager:
"""Cancel all messages in all trees."""
async with self._lock:
root_ids = list(self._repository.tree_ids())
all_cancelled: list[MessageNode] = []
for root_id in root_ids:
all_cancelled.extend(await self.cancel_tree(root_id))
return all_cancelled
all_cancelled: list[MessageNode] = []
for root_id in root_ids:
all_cancelled.extend(await self.cancel_tree(root_id))
return all_cancelled
def cleanup_stale_nodes(self) -> int:
"""