Skip to content

Commit d2db947

Browse files
committed
rename key
1 parent 2e9cc8a commit d2db947

File tree

1 file changed

+6
-33
lines changed

1 file changed

+6
-33
lines changed

packages/service-library/tests/redis/test_semaphore_decorator.py

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -458,37 +458,6 @@ async def limited_function(call_id: int):
458458
async def test_context_manager_basic_functionality(
459459
redis_client_sdk: RedisClientSDK,
460460
semaphore_name: str,
461-
):
462-
call_count = 0
463-
464-
@with_limited_concurrency_cm(
465-
redis_client_sdk,
466-
key=semaphore_name,
467-
capacity=1,
468-
)
469-
@asynccontextmanager
470-
async def limited_context_manager():
471-
nonlocal call_count
472-
call_count += 1
473-
yield call_count
474-
475-
# Multiple concurrent context managers
476-
async def use_context_manager() -> int:
477-
async with limited_context_manager() as value:
478-
await asyncio.sleep(0.1)
479-
return value
480-
481-
tasks = [asyncio.create_task(use_context_manager()) for _ in range(3)]
482-
results = await asyncio.gather(*tasks)
483-
484-
# All should complete successfully
485-
assert len(results) == 3
486-
assert all(isinstance(r, int) for r in results)
487-
488-
489-
async def test_context_manager_capacity_enforcement(
490-
redis_client_sdk: RedisClientSDK,
491-
semaphore_name: str,
492461
):
493462
concurrent_count = 0
494463
max_concurrent = 0
@@ -510,13 +479,17 @@ async def limited_context_manager():
510479
finally:
511480
concurrent_count -= 1
512481

513-
async def use_context_manager() -> None:
482+
async def use_context_manager() -> int:
514483
async with limited_context_manager():
515484
await asyncio.sleep(0.1)
485+
return 1
516486

517487
# Start concurrent context managers
518488
tasks = [asyncio.create_task(use_context_manager()) for _ in range(20)]
519-
await asyncio.gather(*tasks)
489+
results = await asyncio.gather(*tasks)
490+
# All should complete successfully
491+
assert len(results) == 20
492+
assert all(isinstance(r, int) for r in results)
520493

521494
# Should never exceed capacity of 2
522495
assert max_concurrent <= 2

0 commit comments

Comments
 (0)