HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //proc/722141/root/lib/python3.6/site-packages/rsa/__pycache__/parallel.cpython-36.pyc
3

�Cb`e	�@s�dZddlZddlmZddlZddlZeedd�dd�Z	eeed�dd	�Z
d	gZed
kr�e
d�ddlZx>ed�D]2Zej�\ZZer�Ped
dkrterte
de�qtWe
d�dS)z�Functions for parallel computation on multiple cores.

Introduced in Python-RSA 3.1.

.. note::

    Requires Python 2.6 or newer.

�N)�
Connection)�nbits�pipe�returncCs0x*tjj|�}tjj|�r|j|�dSqWdS)N)�rsaZrandnumZread_random_odd_intZprimeZis_prime�send)rrZinteger�r�/usr/lib/python3.6/parallel.py�_find_prime s

r
)r�poolsizerc
sxtjdd�\}�z:��fdd�t|�D�}x|D]}|j�q0W|j�}Wd|j��j�Xx|D]}|j�qdW|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)Zduplexcsg|]}tjt��fd��qS))�target�args)�mpZProcessr
)�.0�_)r�	pipe_sendrr	�
<listcomp>Aszgetprime.<locals>.<listcomp>N)rZPipe�range�startZrecv�closeZ	terminate)rrZ	pipe_recvZprocs�p�resultr)rrr	�getprime*s


r�__main__z'Running doctests 1000x or until failure�d�
z%i timesz
Doctests done)�__doc__ZmultiprocessingrZmultiprocessing.connectionrZ	rsa.primerZrsa.randnum�intr
r�__all__�__name__�printZdoctestr�countZtestmodZfailuresZtestsrrrr	�<module>s"
(