mirror of
https://github.com/Alishahryar1/free-claude-code.git
synced 2026-07-03 14:05:26 +02:00
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:
@@ -66,7 +66,7 @@ if DISCORD_AVAILABLE and _discord_module is not None:
|
||||
|
||||
async def on_ready(self) -> None:
|
||||
"""Called when the bot is ready."""
|
||||
self._platform._set_connected(True)
|
||||
self._platform._connected = True
|
||||
logger.info("Discord platform connected")
|
||||
|
||||
async def on_message(self, message: Any) -> None:
|
||||
@@ -118,10 +118,6 @@ class DiscordPlatform(MessagingPlatform):
|
||||
self._pending_voice: dict[tuple[str, str], tuple[str, str]] = {}
|
||||
self._pending_voice_lock = asyncio.Lock()
|
||||
|
||||
def _set_connected(self, connected: bool) -> None:
|
||||
"""Update connection state via an explicit accessor."""
|
||||
self._connected = connected
|
||||
|
||||
async def _handle_client_message(self, message: Any) -> None:
|
||||
"""Adapter entry point used by the internal discord client."""
|
||||
await self._on_discord_message(message)
|
||||
@@ -367,7 +363,7 @@ class DiscordPlatform(MessagingPlatform):
|
||||
async def stop(self) -> None:
|
||||
"""Stop the bot."""
|
||||
if self._client.is_closed():
|
||||
self._set_connected(False)
|
||||
self._connected = False
|
||||
return
|
||||
|
||||
await self._client.close()
|
||||
@@ -379,7 +375,7 @@ class DiscordPlatform(MessagingPlatform):
|
||||
with contextlib.suppress(asyncio.CancelledError):
|
||||
await self._start_task
|
||||
|
||||
self._set_connected(False)
|
||||
self._connected = False
|
||||
logger.info("Discord platform stopped")
|
||||
|
||||
async def send_message(
|
||||
|
||||
Reference in New Issue
Block a user