From 488c91d758bd5e3342045e7a08b2e06750be1561 Mon Sep 17 00:00:00 2001 From: whatevertogo Date: Thu, 12 Mar 2026 22:59:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E5=81=9C=E6=AD=A2=20Peer=20?= =?UTF-8?q?=E5=AE=9E=E4=BE=8B=E5=B9=B6=E6=9B=B4=E6=96=B0=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E4=BB=A5=E9=AA=8C=E8=AF=81=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-new/astrbot_sdk/runtime/peer.py | 1 + tests_v4/test_peer.py | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src-new/astrbot_sdk/runtime/peer.py b/src-new/astrbot_sdk/runtime/peer.py index 5af890e69..531f348cf 100644 --- a/src-new/astrbot_sdk/runtime/peer.py +++ b/src-new/astrbot_sdk/runtime/peer.py @@ -102,6 +102,7 @@ class Peer: raise AstrBotError.protocol_error("initialize 必须收到 initialize_result") if not result.success: self._unusable = True + await self.stop() raise AstrBotError.from_payload(result.error.model_dump() if result.error else {}) output = InitializeOutput.model_validate(result.output) self.remote_peer = output.peer diff --git a/tests_v4/test_peer.py b/tests_v4/test_peer.py index 5ca26d44e..cad7aaa17 100644 --- a/tests_v4/test_peer.py +++ b/tests_v4/test_peer.py @@ -220,9 +220,9 @@ class PeerRuntimeTest(unittest.IsolatedAsyncioTestCase): self.assertEqual(raised.exception.code, "protocol_version_mismatch") await asyncio.wait_for(core.wait_closed(), timeout=1.0) + await asyncio.wait_for(plugin.wait_closed(), timeout=1.0) self.assertTrue(core._closed) - - await plugin.stop() + self.assertTrue(plugin._closed) class CapabilityRouterContractTest(unittest.TestCase):