Exemplo n.º 1
0
def test_pipespeed():
    c, d = processing.Pipe()
    cond = processing.Condition()
    elapsed = 0
    iterations = 1

    while elapsed < delta:
        iterations *= 2

        p = processing.Process(target=pipe_func, args=(d, cond, iterations))
        cond.acquire()
        p.start()
        cond.wait()
        cond.release()

        result = None
        t = _timer()

        while result != 'STOP':
            result = c.recv()

        elapsed = _timer() - t
        p.join()

    print(iterations, 'objects passed through connection in',elapsed,'seconds')
    print('average number/sec:', iterations/elapsed)
Exemplo n.º 2
0
def run(params:List[Parameter],bt_log:bool, pe:bool) -> pandas.DataFrame: 
    
    njobs = len(params)
    results = []
    jobs = []
    receivers = []
    for i in range(njobs) : 
        initializer = Initializer(params[i].population_size,params[i].landscape) 
        init_pop = initializer.init_with_const(params[i].nucleotides, params[i].base_paires)
        receiver, sender = mp.Pipe(False)
        p = mp.Process(target=ea_without_crossover, args=(init_pop, params[i], bt_log, pe,sender,))
        jobs.append(p)
        receivers.append(receiver)
    
    for i  in range(njobs) : 
        jobs[i].start()
        results.append(receivers[i].recv())
        jobs[i].join()
    
    
    best_solutions = []
    for rst in results : 
        for ind in rst[1]: 
            if ind.fitness == 1.0 : 
                best_solutions.append([ind.rna_sequence, ind.fitness, ind.mfe,1/landscape.ens_defect(params.landscape.target_structure,ind.rna_sequence)])
    df = pandas.DataFrame(best_solutions, columns=["Sequence", "Fitness","MFE","ED"])

    return df
Exemplo n.º 3
0
 def __call__(self):
     """Execute the embedded function object asynchronously.
     The function given to the constructor is transparently called and
     requires that "ready" be intermittently polled. If and when it is
     True, the "value" property may then be checked for returned data.
     """
     self.__parent_conn, self.wrap_helper.child_conn = multiprocess.Pipe(
         duplex=False)
     self.__process = multiprocess.Process(target=_target,
                                           args=[self.wrap_helper])
     # daemonic process must not have subprocess - we need that for nested decorators
     self.__process.daemon = False
     self.__process.start()
     if not self.wrap_helper.dec_hard_timeout:
         self.wait_until_process_started()
     if self.__parent_conn.poll(self.wrap_helper.dec_timeout):
         return self.value
     else:
         self.cancel()
Exemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     mp.Process.__init__(self, *args, **kwargs)
     self._pconn, self._cconn = mp.Pipe()
     self._exception = None
Exemplo n.º 5
0
    def w_make_pair(self):
        import multiprocess

        return multiprocess.Pipe(duplex=False)