HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/rsa/__pycache__/parallel.cpython-37.pyc
B

��fe	�@s�dZddlZddlmZddlZddlZeedd�dd�Z	eeed�dd	�Z
d	gZed
kr�e
d�ddlZx>ed�D]2Ze��\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*tj�|�}tj�|�r|�|�dSqWdS)N)�rsaZrandnumZread_random_odd_int�primeZis_prime�send)rr�integer�r
�=/opt/alt/python37/lib/python3.7/site-packages/rsa/parallel.py�_find_prime s

r)r�poolsizercsxtjdd�\}�z:��fdd�t|�D�}x|D]}|��q0W|��}Wd|�����Xx|D]}|��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)�mp�Processr)�.0�_)r�	pipe_sendr
r�
<listcomp>Aszgetprime.<locals>.<listcomp>N)rZPipe�range�start�recv�close�	terminate)rr
Z	pipe_recvZprocs�p�resultr
)rrr�getprime*s


r�__main__z'Running doctests 1000x or until failure�d�
z%i timesz
Doctests done)�__doc__�multiprocessingrZmultiprocessing.connectionrZ	rsa.primerZrsa.randnum�intrr�__all__�__name__�print�doctestr�count�testmodZfailures�testsr
r
r
r�<module>s"
(