Пример #1
0
 def __init__(self, model, func, n_jobs, persist_method):
     if isinstance(model, PersistedModel):
         key = model
     else:
         key = persist(model, method=persist_method)
     func = pickle.dumps(func)
     ctx = LKContext.INSTANCE
     kid_tc = proc_count(level=1)
     os.environ['_LK_IN_MP'] = 'yes'
     _log.info('setting up multiprocessing.Pool w/ %d workers', n_jobs)
     self.pool = ctx.Pool(n_jobs, _initialize_mp_worker,
                          (key, func, kid_tc, log_queue(), get_root_seed()))
Пример #2
0
    def __init__(self, model, func, n_jobs, persist_method):
        if isinstance(model, PersistedModel):
            _log.debug('model already persisted')
            key = model
        else:
            _log.debug('persisting model with method %s', persist_method)
            key = persist(model, method=persist_method)
            self._close_key = key

        _log.debug('persisting function')
        func = pickle.dumps(func)
        ctx = LKContext.INSTANCE
        _log.info('setting up ProcessPoolExecutor w/ %d workers', n_jobs)
        os.environ['_LK_IN_MP'] = 'yes'
        kid_tc = proc_count(level=1)
        self.executor = ProcessPoolExecutor(
            n_jobs, ctx, _initialize_mp_worker,
            (key, func, kid_tc, log_queue(), get_root_seed()))
Пример #3
0
def test_sp_random_seed():
    init = get_root_seed()
    seed = run_sp(_get_seed)
    # we should spawn a seed for the worker
    assert seed.entropy == init.entropy
    assert seed.spawn_key == (init.n_children_spawned - 1, )
Пример #4
0
def _get_seed():
    return get_root_seed()