Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/test/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/test/__pycache__/test_multiprocessing_main_handling.cpython-312.pyc

�

'Μg�-��D�ddlmZddlmZejd�ddlZddlZddlZddlZddl	Z	ddl
Z	ddlZddlmZddl
mZmZmZmZmZej&rej(d��ddlZeej.��Zej2�ej4ZdZd	Zed
fd�Zedfd
�ZdZdd�Z Gd�d�Z!Gd�de!ejD�Z#Gd�de!ejD�Z$Gd�de!ejD�Z%d�Z&e'dk(rejP�yy)�)�support)�
import_helper�_multiprocessingN)�	os_helper)�make_pkg�make_script�make_zip_pkg�make_zip_script�assert_python_okztest is not helpful for PGOaT# multiprocessing includes all sorts of shenanigans to make __main__
# attributes accessible in the subprocess in a pickle compatible way.

# We run the "doesn't work in the interactive interpreter" example from
# the docs to make sure it *does* work from an executed __main__,
# regardless of the invocation mechanism

import sys
import time
from multiprocessing import Pool, set_start_method
from test import support

# We use this __main__ defined function in the map call below in order to
# check that multiprocessing in correctly running the unguarded
# code in child processes and then making it available as __main__
def f(x):
    return x*x

# Check explicit relative imports
if "check_sibling" in __file__:
    # We're inside a package and not in a __main__.py file
    # so make sure explicit relative imports work correctly
    from . import sibling

if __name__ == '__main__':
    start_method = sys.argv[1]
    set_start_method(start_method)
    results = []
    with Pool(5) as pool:
        pool.map_async(f, [1, 2, 3], callback=results.extend)

        # up to 1 min to report the results
        for _ in support.sleeping_retry(support.LONG_TIMEOUT,
                                        "Timed out waiting for results"):
            if results:
                break

    results.sort()
    print(start_method, "->", results)

    pool.join()
ao# __main__.py files have an implied "if __name__ == '__main__'" so
# multiprocessing should always skip running them in child processes

# This means we can't use __main__ defined functions in child processes,
# so we just use "int" as a passthrough operation below

if __name__ != "__main__":
    raise RuntimeError("Should only be called as __main__!")

import sys
import time
from multiprocessing import Pool, set_start_method
from test import support

start_method = sys.argv[1]
set_start_method(start_method)
results = []
with Pool(5) as pool:
    pool.map_async(int, [1, 4, 9], callback=results.extend)
    # up to 1 min to report the results
    for _ in support.sleeping_retry(support.LONG_TIMEOUT,
                                    "Timed out waiting for results"):
        if results:
            break

results.sort()
print(start_method, "->", results)

pool.join()
Fc�n�t||||�}|dk(r
t|dd�tj�|S)N�
check_sibling�sibling�)r�	importlib�invalidate_caches)�
script_dir�script_basename�source�omit_suffix�	to_returns     �D/usr/local/lib/python3.12/test/test_multiprocessing_main_handling.py�_make_test_scriptrns=���J��"�K�1�I��/�)��J�	�2�.�
���!����c�N�t||||||�}tj�|S�N)r	rr)�zip_dir�zip_basename�pkg_namerr�depthrs       r�_make_test_zip_pkgr!xs+���W�l�H�o�#�U�,�I�
���!��rzPimport sys, os.path, runpy
sys.path.insert(0, %s)
runpy._run_module_as_main(%r)
c�~�|�d}nt|�}t||fz}t|||�}tj�|S)Nzos.path.dirname(__file__))�repr�
launch_sourcerrr)rr�module_name�pathrrs      r�_make_launch_scriptr'�sD���|�*���D�z��
�d�K�0�
0�F��J���@�I�
���!��rc�p�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zy)�MultiProcessingCmdLineMixinNc�f�|jtvr|jd|jz�yy)Nz%r start method not available)�start_method�AVAILABLE_START_METHODS�skipTest)�selfs r�setUpz!MultiProcessingCmdLineMixin.setUp�s.�����$;�;��M�M�9�D�<M�<M�M�N�<rc�<�tdkDr"td|z�tt|��|j|d�|j|j	d�d�d|j
z}|j|j	d�j
�|�y)NrzOutput from test script %r:rzutf-8rz%s -> [1, 4, 9])�verbose�printr#�assertEqual�decoder+�strip)r.�script_name�	exit_code�out�err�expected_resultss      r�
_check_outputz)MultiProcessingCmdLineMixin._check_output�s����Q�;��/�+�=�>��$�s�)������A�&�������G�,�b�1�,�t�/@�/@�@��������G�,�2�2�4�6F�Grc�n�	|||jfz}t	|ddi�\}}}|j||||�y)NF�
__isolated)�sys�flags�optimizer+rr;)r.r6�cmd_line_switches�run_args�rcr8r9s       r�
_check_scriptz)MultiProcessingCmdLineMixin._check_script�sC���$��T�5F�5F�'G�G��'��D�e�D���C�����;��C��5rc��tj�5}t|d�}|j|�ddd�y#1swYyxYw)N�script�r�temp_dirrrD�r.rr6s   r�test_basic_scriptz-MultiProcessingCmdLineMixin.test_basic_script�s6��
�
�
�
!�Z�+�J��A�K����{�+�"�
!�
!�s	�<�Ac��tj�5}t|dd��}|j|�ddd�y#1swYyxYw)NrFT)rrGrIs   r�test_basic_script_no_suffixz7MultiProcessingCmdLineMixin.test_basic_script_no_suffix�s;��
�
�
�
!�Z�+�J��8<�>�K����{�+�"�
!�
!�s	� >�Ac���t}tj�5}t|d|��}|j	|�t|d|d��}|j	|�ddd�y#1swYyxYw)N�ipython�rT)rr)�$test_source_main_skipped_in_childrenrrHrrD)r.rrr6�script_no_suffixs     r�test_ipython_workaroundz3MultiProcessingCmdLineMixin.test_ipython_workaround�si��
6��
�
�
�
!�Z�+�J�	�39�;�K����{�+�0��Y�8>�=A� C��
���/�0�"�
!�
!�s�AA$�$A-c��tj�5}t|d�}tj|d��tj|�tj|�}|j|�ddd�y#1swYyxYw)NrFT��doraise)
rrHr�
py_compile�compile�os�remover�make_legacy_pycrD)r.rr6�pyc_files    r�test_script_compiledz0MultiProcessingCmdLineMixin.test_script_compiled�sb��
�
�
�
!�Z�+�J��A�K����{�D�9��I�I�k�"�$�4�4�[�A�H����x�(�"�
!�
!�s�AA=�=Bc��|j}tj�5}t|d|��}|j	|�ddd�y#1swYyxYw)N�__main__rO)�main_in_children_sourcerrHrrD)r.rrr6s    r�test_directoryz*MultiProcessingCmdLineMixin.test_directory�sF���-�-��
�
�
�
!�Z�+�J�
�39�;�K����z�*�"�
!�
!�s� A
�
Ac�.�|j}tj�5}t|d|��}t	j
|d��t
j|�tj|�}|j|�ddd�y#1swYyxYw)Nr^rOTrT)r_rrHrrVrWrXrYrrZrD)r.rrr6r[s     r�test_directory_compiledz3MultiProcessingCmdLineMixin.test_directory_compiled�sr���-�-��
�
�
�
!�Z�+�J�
�39�;�K����{�D�9��I�I�k�"�$�4�4�[�A�H����z�*�
"�
!�
!�s�A!B�Bc���|j}tj�5}t|d|��}t	|d|�\}}|j|�ddd�y#1swYyxYw)Nr^rO�test_zip)r_rrHrr
rD)r.rrr6�zip_name�run_names      r�test_zipfilez(MultiProcessingCmdLineMixin.test_zipfile�sY���-�-��
�
�
�
!�Z�+�J�
�39�;�K�!0��Z��!U��H�h����x�(�	"�
!�
!�s�0A�A#c��|j}tj�5}t|d|��}t	j
|d��}t
|d|�\}}|j|�ddd�y#1swYyxYw)Nr^rOTrTrd)r_rrHrrVrWr
rD)r.rrr6�
compiled_namererfs       r�test_zipfile_compiledz1MultiProcessingCmdLineMixin.test_zipfile_compiled�sk���-�-��
�
�
�
!�Z�+�J�
�39�;�K�&�.�.�{�D�I�M�!0��Z��!W��H�h����x�(�"�
!�
!�s�AA1�1A:c��tj�5}tjj	|d�}t|�t
|d�}t|dd�}|j|�ddd�y#1swYyxYw)N�test_pkgr
�launchztest_pkg.check_sibling)	rrHrXr&�joinrrr'rD)r.r�pkg_dirr6�launch_names     r�test_module_in_packagez2MultiProcessingCmdLineMixin.test_module_in_package�sd��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��+�G�_�E�K�-�j�(�.F�H�K����{�+�
"�
!�
!�s�AA4�4A=c��tj�5}t|ddd�\}}t|dd|�}|j	|�ddd�y#1swYyxYw)NrdrlrFrmztest_pkg.script�rrHr!r'rD�r.rrerfrps     r�!test_module_in_package_in_zipfilez=MultiProcessingCmdLineMixin.test_module_in_package_in_zipfile�sR��
�
�
�
!�Z�!3�J�
�J�X`�!a��H�h�-�j�(�DU�W_�`�K����{�+�"�
!�
!�s�1A�Ac��tj�5}t|dddd��\}}t|dd|�}|j	|�ddd�y#1swYyxYw)NrdrlrF�)r rmztest_pkg.test_pkg.scriptrsrts     r�$test_module_in_subpackage_in_zipfilez@MultiProcessingCmdLineMixin.test_module_in_subpackage_in_zipfile�sU��
�
�
�
!�Z�!3�J�
�J�X`�hi�!j��H�h�-�j�(�D^�`h�i�K����{�+�"�
!�
!�s�3A�Ac��|j}tj�5}tjj|d�}t
|�t|d|��}t|dd�}|j|�ddd�y#1swYyxYw)Nrlr^rOrm)
r_rrHrXr&rnrrr'rD)r.rrror6rps      r�test_packagez(MultiProcessingCmdLineMixin.test_packagesp���-�-��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��+�G�Z�39�;�K�-�j�(�J�O�K����{�+�
"�
!�
!�s�AB�Bc��|j}tj�5}tjj|d�}t
|�t|d|��}tj|d��}tj|�tj|�}t|dd�}|j|�ddd�y#1swYyxYw)Nrlr^rOTrTrm)r_rrHrXr&rnrrrVrWrYrrZr'rD)r.rrror6rir[rps        r�test_package_compiledz1MultiProcessingCmdLineMixin.test_package_compiled
s����-�-��
�
�
�
!�Z��g�g�l�l�:�z�:�G��W��+�G�Z�39�;�K�&�.�.�{�D�I�M��I�I�k�"�$�4�4�[�A�H�-�j�(�J�O�K����{�+�"�
!�
!�s�BC�C)�__name__�
__module__�__qualname__�maxDiffr/r;rDrJrLrRr\r`rbrgrjrqrurxrzr|�rrr)r)�sY���G�O�H�6�,�
,�
1�)�+�+�)�)�,�,�,�,�,rr)c��eZdZdZeZy)�SpawnCmdLineTest�spawnN�r}r~rr+rPr_r�rrr�r�s
���L�B�rr�c��eZdZdZeZy)�ForkCmdLineTest�forkN)r}r~rr+�test_sourcer_r�rrr�r� s
���L�)�rr�c��eZdZdZeZy)�ForkServerCmdLineTest�
forkserverNr�r�rrr�r�$s
���L�B�rr�c�,�tj�yr)r�
reap_childrenr�rr�tearDownModuler�(s�����rr^r))�testr�test.supportr�
import_moduler�importlib.machinery�unittestr>rX�os.pathrVr�test.support.script_helperrrr	r
r�PGO�SkipTest�multiprocessing�set�get_all_start_methodsr,�*skip_if_broken_multiprocessing_synchronizer1r�rPrr!r$r'r)�TestCaser�r�r�r�r}�mainr�rr�<module>r�s4���&��
���.�/����
�	���"����;�;�
�(�
�
�9�
:�:���C�o�C�C�E�F��3��2�2�4�
�/�/��*��X(�$�F)�e��*����
��E,�E,�RC�2�H�4E�4E�C�*�1�8�3D�3D�*�C�7��9J�9J�C���z���H�M�M�O�r

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists