async def test_state_manager_lock_expire_contend(
    state_manager_redis: StateManagerRedis, token: str, substate_token_redis: str
):
    """Test that the state manager lock expires and queued waiters proceed.

    Args:
        state_manager_redis: A state manager instance.
        token: A token.
        substate_token_redis: A token + substate name for looking up in state manager.
    """
    exp_num1 = 4252
    unexp_num1 = 666

    state_manager_redis.lock_expiration = LOCK_EXPIRATION
    state_manager_redis.lock_warning_threshold = LOCK_WARNING_THRESHOLD

    order = []
    waiter_event = asyncio.Event()

    async def _coro_blocker():
        async with state_manager_redis.modify_state(substate_token_redis) as state:
            order.append("blocker")
            waiter_event.set()
            await asyncio.sleep(LOCK_EXPIRE_SLEEP)
            state.num1 = unexp_num1

    async def _coro_waiter():
        await waiter_event.wait()
        async with state_manager_redis.modify_state(substate_token_redis) as state:
            order.append("waiter")
            assert state.num1 != unexp_num1
            state.num1 = exp_num1

    tasks = [
        asyncio.create_task(_coro_blocker()),
        asyncio.create_task(_coro_waiter()),
    ]
    with pytest.raises(LockExpiredError):
        await tasks[0]
    await tasks[1]

    assert order == ["blocker", "waiter"]
    assert (await state_manager_redis.get_state(substate_token_redis)).num1 == exp_num1
Test that the state manager lock expires and queued waiters proceed.

    Args:
        state_manager_redis: A state manager instance.
        token: A token.
        substate_token_redis: A token + substate name for looking up in state manager.
    
tests/units/test_state.py