Skip to content

Commit 9774797

Browse files
committed
we are fair?
1 parent 0188254 commit 9774797

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,8 +422,19 @@ async def limited_function() -> None:
422422
assert "longer than expected" in caplog.messages[-1]
423423

424424

425-
@pytest.mark.skip
425+
@pytest.fixture
426+
def with_slow_redis_socket_timeout(
427+
mock_redis_socket_timeout: None, mocker: MockerFixture
428+
) -> None:
429+
# put back to higher value to allow normal operations
430+
mocker.patch(
431+
"servicelib.redis._client.DEFAULT_SOCKET_TIMEOUT",
432+
datetime.timedelta(seconds=30),
433+
)
434+
435+
426436
async def test_semaphore_fair_queuing(
437+
with_slow_redis_socket_timeout: None,
427438
redis_client_sdk: RedisClientSDK,
428439
semaphore_name: str,
429440
):
@@ -436,15 +447,15 @@ async def test_semaphore_fair_queuing(
436447
)
437448
async def limited_function(call_id: int):
438449
entered_order.append(call_id)
439-
await asyncio.sleep(0.1)
450+
await asyncio.sleep(0.2)
440451
return call_id
441452

442453
# Launch tasks in a specific order
443454
num_tasks = 10
444455
tasks = []
445456
for i in range(num_tasks):
446457
tasks.append(asyncio.create_task(limited_function(i)))
447-
await asyncio.sleep(0.01) # Small delay to help preserve order
458+
await asyncio.sleep(0.1) # Small delay to help preserve order
448459
results = await asyncio.gather(*tasks)
449460

450461
# All should complete successfully and in order

0 commit comments

Comments
 (0)