File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
packages/service-library/tests/redis Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -398,25 +398,30 @@ async def test_with_large_capacity(
398398 redis_client_sdk : RedisClientSDK ,
399399 semaphore_name : str ,
400400):
401- large_capacity = 1000
401+ large_capacity = 200
402402 concurrent_count = 0
403403 max_concurrent = 0
404+ sleep_time_s = 30
405+ num_tasks = 400
404406
405407 @with_limited_concurrency (
406408 redis_client_sdk ,
407409 key = semaphore_name ,
408410 capacity = large_capacity ,
411+ blocking = True ,
412+ blocking_timeout = None ,
409413 )
410414 async def limited_function ():
411415 nonlocal concurrent_count , max_concurrent
412416 concurrent_count += 1
413417 max_concurrent = max (max_concurrent , concurrent_count )
414- await asyncio .sleep (60 )
418+ await asyncio .sleep (30 )
415419 concurrent_count -= 1
416420
417421 # Start tasks equal to the large capacity
418- tasks = [asyncio .create_task (limited_function ()) for _ in range (large_capacity )]
419- await asyncio .gather (* tasks )
422+ tasks = [asyncio .create_task (limited_function ()) for _ in range (num_tasks )]
423+ async with asyncio .timeout (num_tasks / large_capacity * 1.5 * sleep_time_s ):
424+ await asyncio .gather (* tasks )
420425
421426 # Should never exceed the large capacity
422427 assert max_concurrent <= large_capacity
You can’t perform that action at this time.
0 commit comments