
    ge	                        d Z ddlZddlmZ ddlZddlZdededdfdZ	dededefd	Z
d
gZedk(  rQ ed       ddlZ ed      D ]1  Z ej"                         \  ZZer nedz  dk(  s$es' edez         3  ed       yy)zFunctions for parallel computation on multiple cores.

Introduced in Python-RSA 3.1.

.. note::

    Requires Python 2.6 or newer.

    N)
Connectionnbitspipereturnc                     	 t         j                  j                  |       }t         j                  j	                  |      r|j                  |       y Q)N)rsarandnumread_random_odd_intprimeis_primesend)r   r   integers      A/var/www/openai/venv/lib/python3.12/site-packages/rsa/parallel.py_find_primer       sA    
++11%8 99g&IIg     poolsizec                    t        j                  d      \  }}	 t        |      D cg c]  }t        j                  t        | |f      ! }}|D ]  }|j                           |j                         }|j                          |j                          |D ]  }|j                           |S c c}w # |j                          |j                          w xY w)aU  Returns 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)duplex)targetargs)	mpPiperangeProcessr   startrecvclose	terminate)r   r   	pipe_recv	pipe_send_procspresults           r   getprimer%   *   s    &  WWE2Y		RWX`RabRaQ;eY5GHRabAGGI  ! 	  M c 	s   B3 $B.)B3 .B3 3"Cr%   __main__z'Running doctests 1000x or until failured   
   z%i timeszDoctests done)__doc__multiprocessingr   multiprocessing.connectionr   	rsa.primer   rsa.randnumintr   r%   __all____name__printdoctestr   counttestmodfailurestests r   r   <module>r8      s     1  s *  %C %3 %3 %P ,z	
34s+GOO-52:?u*u$%  
/ r   