From d920c9093671347b173a630d77f818f5bccfbf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=91=B5=E5=91=B5=E3=81=A7=E3=81=99?= <51957264+shoucandanghehe@users.noreply.github.com> Date: Mon, 22 Dec 2025 02:25:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=88=9B=E5=BB=BA=E6=B5=8F=E8=A7=88=E5=99=A8=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=E7=9A=84bug=20(#567)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_tetris_stats/utils/browser.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nonebot_plugin_tetris_stats/utils/browser.py b/nonebot_plugin_tetris_stats/utils/browser.py index 9053180..f77ba32 100644 --- a/nonebot_plugin_tetris_stats/utils/browser.py +++ b/nonebot_plugin_tetris_stats/utils/browser.py @@ -95,9 +95,11 @@ class BrowserManager: cls, context_id: str = 'default', factory: Callable[[], Coroutine[Any, Any, BrowserContext]] | None = None ) -> BrowserContext: """获取浏览器上下文""" - return cls._contexts.setdefault( - context_id, await factory() if factory is not None else await (await cls.get_browser()).new_context() - ) + context = cls._contexts.get(context_id) + if context is None: + context = await (factory or (await cls.get_browser()).new_context)() + cls._contexts[context_id] = context + return context @classmethod async def del_context(cls, context_id: str) -> None: