import multiprocessing


def get_n_workers(n_workers, params):
    """Determine the number of workers."""

    n_workers = min(n_workers, multiprocessing.cpu_count())

    try:
        n_workers = min(n_workers, params['n_workers'])
    except:
        pass

    return n_workers