From 40de0e47e5a8719c4834159f394e9d98f72ff807 Mon Sep 17 00:00:00 2001 From: persist-1 Date: Mon, 8 Sep 2025 00:29:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(store):=20=E5=B0=86async=20for=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E6=9B=BF=E6=8D=A2=E4=B8=BAasync=20with=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E6=9D=A5=E4=BF=AE=E5=A4=8Dzhihu=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E4=BC=9A=E8=AF=9D=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/zhihu/_store_impl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/store/zhihu/_store_impl.py b/store/zhihu/_store_impl.py index 9dfaf23..d2d6c4e 100644 --- a/store/zhihu/_store_impl.py +++ b/store/zhihu/_store_impl.py @@ -93,9 +93,9 @@ class ZhihuDbStoreImplement(AbstractStore): Args: content_item: content item dict """ - note_id = content_item.get("note_id") - async for session in get_session(): - stmt = select(ZhihuContent).where(ZhihuContent.content_id == note_id) + content_id = content_item.get("content_id") + async with get_session() as session: + stmt = select(ZhihuContent).where(ZhihuContent.content_id == content_id) result = await session.execute(stmt) existing_content = result.scalars().first() if existing_content: @@ -113,7 +113,7 @@ class ZhihuDbStoreImplement(AbstractStore): comment_item: comment item dict """ comment_id = comment_item.get("comment_id") - async for session in get_session(): + async with get_session() as session: stmt = select(ZhihuComment).where(ZhihuComment.comment_id == comment_id) result = await session.execute(stmt) existing_comment = result.scalars().first() @@ -132,7 +132,7 @@ class ZhihuDbStoreImplement(AbstractStore): creator: creator dict """ user_id = creator.get("user_id") - async for session in get_session(): + async with get_session() as session: stmt = select(ZhihuCreator).where(ZhihuCreator.user_id == user_id) result = await session.execute(stmt) existing_creator = result.scalars().first()