o j` @sdZddlZddlmZddlZddlZdededdfddZ ded edefd d Z d gZ e d kr^e d ddlZedD]Ze\ZZerIneddkrWerWe deq=e ddSdS)zFunctions for parallel computation on multiple cores. Introduced in Python-RSA 3.1. .. note:: Requires Python 2.6 or newer. N) ConnectionnbitspipereturncCs* tj|}tj|r||dSq)N)rsarandnumread_random_odd_intprimeis_primesend)rrintegerr ./usr/lib/python3/dist-packages/rsa/parallel.py _find_prime s    rpoolsizecstjdd\}z#fddt|D}|D]}|q|}W|n |w|D]}|q7|S)aUReturns a prime number that can be stored in 'nbits' bits. Works in multiple threads at the same time. >>> p = getprime(128, 3) >>> rsa.prime.is_prime(p-1) False >>> rsa.prime.is_prime(p) True >>> rsa.prime.is_prime(p+1) False >>> from rsa import common >>> common.bit_size(p) == 128 True F)duplexcsg|] }tjtfdqS))targetargs)mpProcessr).0_r pipe_sendr r Aszgetprime..)rPiperangestartrecvclose terminate)rr pipe_recvprocspresultr rrgetprime*s     r%__main__z'Running doctests 1000x or until failured z%i timesz Doctests done)__doc__multiprocessingrmultiprocessing.connectionr rsa.primer rsa.randnumintrr%__all____name__printdoctestrcounttestmodfailurestestsr r r rs(  (