<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pool_boy(Pool, traces, **kwargs):
 """ A context manager for handling the setup and cleanup of a pool object. :param Pool: any Class (not instance) that implements the multiprocessing Pool interface :param traces: The number of traces to process :type traces: int """

    # All parallel processing happens on a per-trace basis, we shouldn't create
    # more workers than there are traces
    n_cores = kwargs.get('cores', cpu_count())
    if n_cores is None:
        n_cores = cpu_count()
    if n_cores > traces:
        n_cores = traces
    pool = Pool(n_cores)
    yield pool
    pool.close()
    pool.join()