From bf9e4d481141c89d6d1b5f301ed9b0b2ad880b62 Mon Sep 17 00:00:00 2001 From: ThearchyHelios Date: Mon, 19 Oct 2026 13:35:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=9A=E9=A2=9D=E5=BA=A6?= =?UTF-8?q?=E5=B9=B6=E5=8F=91=E9=82=A3=E6=9D=A1=E5=90=8C=E6=97=B6=E5=8D=A0?= =?UTF-8?q?=E7=9A=84=E4=B8=AA=E6=95=B0=E9=99=8D=E5=88=B0=2010=EF=BC=88?= =?UTF-8?q?=E4=B8=8D=E8=B6=85=E8=BF=87=E8=BF=9E=E6=8E=A5=E6=B1=A0=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E8=83=BD=E7=BB=99=E7=9A=84=E8=BF=9E=E6=8E=A5=E6=95=B0?= =?UTF-8?q?=EF=BC=89=E2=80=94=E2=80=94=E5=85=A8=E9=87=8F=20-n=20auto=20?= =?UTF-8?q?=E6=97=B6=20SQLite=20=E7=9A=84=E6=B1=A0=E5=AD=90=E5=90=84?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E5=85=B1=E7=94=A8=EF=BC=8C=E6=8E=92=E9=98=9F?= =?UTF-8?q?=E7=AD=89=E8=BF=9E=E6=8E=A5=E4=BC=9A=E6=8A=8A=E6=B1=A0=E5=AD=90?= =?UTF-8?q?=E7=9A=84=E9=98=9F=E5=88=97=E7=BB=91=E5=88=B0=E5=89=8D=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=B5=8B=E8=AF=95=E7=9A=84=E4=BA=8B=E4=BB=B6=E5=BE=AA?= =?UTF-8?q?=E7=8E=AF=E4=B8=8A=EF=BC=8C=E8=BF=99=E6=9D=A1=E5=81=B6=E5=8F=91?= =?UTF-8?q?=E6=8A=A5=20bound=20to=20a=20different=20event=20loop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/tests/test_cluster.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/tests/test_cluster.py b/backend/tests/test_cluster.py index 58c6564a..89c708cd 100644 --- a/backend/tests/test_cluster.py +++ b/backend/tests/test_cluster.py @@ -395,7 +395,8 @@ async def _until(check, timeout: float = 10.0) -> None: async def test_a_daily_quota_is_taken_up_to_the_limit_by_concurrent_callers(): - """先占额度再发起(cluster/quota):20 个协程同时占、上限 5,正好 5 个占到;这一天第一次占按已有的记录起算;退回一份又能占。""" + """先占额度再发起(cluster/quota):10 个协程同时占、上限 5,正好 5 个占到;这一天第一次占按已有的记录起算;退回一份又能占。 + (同时占的个数不超过连接池能直接给的连接数:SQLite 的池子是各测试共用的,排队等连接会把它绑到这个测试的事件循环上。)""" from app.cluster import quota name = f"test-quota-{new_id()[:8]}" @@ -403,7 +404,7 @@ async def test_a_daily_quota_is_taken_up_to_the_limit_by_concurrent_callers(): async def seed(_session) -> int: return 2 # 今天已经做过 2 次 - got = await asyncio.gather(*(quota.take(name, 5, seed=seed) for _ in range(20))) + got = await asyncio.gather(*(quota.take(name, 5, seed=seed) for _ in range(10))) assert sum(got) == 3 and await quota.used(name) == 5 assert not await quota.take(name, 5) await quota.give_back(name)