def save_minions(jid, minions, syndic_id=None):
    '''
    Save/update the serialized list of minions for a given job
    '''
    log.debug(
        'Adding minions for job %s%s: %s',
        jid,
        ' from syndic master \'{0}\''.format(syndic_id) if syndic_id else '',
        minions
    )
    serial = salt.payload.Serial(__opts__)

    jid_dir = _jid_dir(jid)
    if syndic_id is not None:
        minions_path = os.path.join(
            jid_dir,
            SYNDIC_MINIONS_P.format(syndic_id)
        )
    else:
        minions_path = os.path.join(jid_dir, MINIONS_P)

    try:
        serial.dump(minions, salt.utils.fopen(minions_path, 'w+b'))
    except __HOLE__ as exc:
        log.error(
            'Failed to write minion list {0} to job cache file {1}: {2}'
            .format(minions, minions_path, exc)
        )
dataset/ETHPy150Open saltstack/salt/salt/returners/local_cache.py/save_minions