HEX
Server: Microsoft-IIS/10.0
System: Windows NT ITPWINWEBSVR22 10.0 build 20348 (Windows Server 2022) AMD64
User: www.conferencesearch.co.uk (0)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: D:/Python311/Lib/test/__pycache__/test_multiprocessing_main_handling.cpython-311.pyc
�

��Vcr/��"�ddlmZddlmZejd��ddlZddlZddlZddlZddl	Z	ddl
Z	ddlZddlmZddl
mZmZmZmZmZejrejd���ddlZeej����Zej��ejZdZd	Zed
fd�Zedfd
�ZdZdd�Z Gd�d��Z!Gd�de!ej"��Z#Gd�de!ej"��Z$Gd�de!ej"��Z%d�Z&e'dkrej(��dSdS)�)�support)�
import_helper�_multiprocessingN)�	os_helper)�make_pkg�make_script�make_zip_pkg�make_zip_script�assert_python_okztest is not helpful for PGOa�# 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

# 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)
        start_time = time.monotonic()
        while not results:
            time.sleep(0.05)
            # up to 1 min to report the results
            dt = time.monotonic() - start_time
            if dt > 60.0:
                raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt)

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

    pool.join()
a�# __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

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)
    start_time = time.monotonic()
    while not results:
        time.sleep(0.05)
        # up to 1 min to report the results
        dt = time.monotonic() - start_time
        if dt > 60.0:
            raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt)

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

pool.join()
Fc�~�t||||��}|dkrt|dd��tj��|S)N�
check_sibling�sibling�)r�	importlib�invalidate_caches)�
script_dir�script_basename�source�omit_suffix�	to_returns     �;D:\Python311\Lib\test\test_multiprocessing_main_handling.py�_make_test_scriptrosP���J��"�K�1�1�I��/�)�/��J�	�2�.�.�.�
��!�!�!����c�T�t||||||��}tj��|S�N)r	rr)�zip_dir�zip_basename�pkg_namerr�depthrs       r�_make_test_zip_pkgr!ys3���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'�sQ����*����D�z�z��
�d�K�0�
0�F��J���@�@�I�
��!�!�!��rc�r�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�ZdS)�MultiProcessingCmdLineMixinNc�`�|jtvr|�d|jz��dSdS)Nz%r start method not available)�start_method�AVAILABLE_START_METHODS�skipTest)�selfs r�setUpz!MultiProcessingCmdLineMixin.setUp�sA����$;�;�	O��M�M�9�D�<M�M�N�N�N�N�N�	O�	Orc��tdkr.td|z��tt|����|�|d��|�|�d��d��d|jz}|�|�d�����|��dS)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�1�1�,�t�/@�@��������G�,�,�2�2�4�4�6F�G�G�G�G�Grc�p�	|||jfz}t	|ddi�\}}}|�||||��dS)NF�-�O�
__isolated)�sys�flags�optimizer+rr;)r.r6�cmd_line_switches�run_args�rcr8r9s       r�
_check_scriptz)MultiProcessingCmdLineMixin._check_script�sR��	C�$��T�5F�'G�G��'��D�e�D�D���C�����;��C��5�5�5�5�5rc��tj��5}t|d��}|�|��ddd��dS#1swxYwYdS)N�script�r�temp_dirrrF�r.rr6s   r�test_basic_scriptz-MultiProcessingCmdLineMixin.test_basic_script�s���
�
�
!�
!�	,�Z�+�J��A�A�K����{�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�&A�A�Ac��tj��5}t|dd���}|�|��ddd��dS#1swxYwYdS)NrHT)rrIrKs   r�test_basic_script_no_suffixz7MultiProcessingCmdLineMixin.test_basic_script_no_suffix�s���
�
�
!�
!�	,�Z�+�J��8<�>�>�>�K����{�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�(A	�	A
�A
c�
�t}tj��5}t|d|���}|�|��t|d|d���}|�|��ddd��dS#1swxYwYdS)N�ipython�rT)rr)�$test_source_main_skipped_in_childrenrrJrrF)r.rrr6�script_no_suffixs     r�test_ipython_workaroundz3MultiProcessingCmdLineMixin.test_ipython_workaround�s���
6��
�
�
!�
!�	1�Z�+�J�	�39�;�;�;�K����{�+�+�+�0��Y�8>�=A� C� C� C��
���/�0�0�0�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1�	1����	1�	1�	1�	1�	1�	1s�AA8�8A<�?A<c�$�tj��5}t|d��}tj|d���tj|��tj|��}|�	|��ddd��dS#1swxYwYdS)NrHT��doraise)
rrJr�
py_compile�compile�os�remover�make_legacy_pycrF)r.rr6�pyc_files    r�test_script_compiledz0MultiProcessingCmdLineMixin.test_script_compiled�s���
�
�
!�
!�	)�Z�+�J��A�A�K���{�D�9�9�9�9��I�k�"�"�"�$�4�[�A�A�H����x�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�A$B�B	�B	c��|j}tj��5}t|d|���}|�|��ddd��dS#1swxYwYdS)N�__main__rQ)�main_in_children_sourcerrJrrF)r.rrr6s    r�test_directoryz*MultiProcessingCmdLineMixin.test_directory�s����-��
�
�
!�
!�	+�Z�+�J�
�39�;�;�;�K����z�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+s�(A�A�Ac�6�|j}tj��5}t|d|���}t	j|d���t
j|��tj	|��}|�
|��ddd��dS#1swxYwYdS)Nr`rQTrV)rarrJrrXrYrZr[rr\rF)r.rrr6r]s     r�test_directory_compiledz3MultiProcessingCmdLineMixin.test_directory_compiled�s����-��
�
�
!�
!�	+�Z�+�J�
�39�;�;�;�K���{�D�9�9�9�9��I�k�"�"�"�$�4�[�A�A�H����z�*�*�*�
	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�	+�	+s�A&B�B�Bc���|j}tj��5}t|d|���}t	|d|��\}}|�|��ddd��dS#1swxYwYdS)Nr`rQ�test_zip)rarrJrr
rF)r.rrr6�zip_name�run_names      r�test_zipfilez(MultiProcessingCmdLineMixin.test_zipfile�s����-��
�
�
!�
!�	)�Z�+�J�
�39�;�;�;�K�!0��Z��!U�!U��H�h����x�(�(�(�		)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�<A$�$A(�+A(c��|j}tj��5}t|d|���}t	j|d���}t
|d|��\}}|�|��ddd��dS#1swxYwYdS)Nr`rQTrVrf)rarrJrrXrYr
rF)r.rrr6�
compiled_namergrhs       r�test_zipfile_compiledz1MultiProcessingCmdLineMixin.test_zipfile_compiled�s����-��
�
�
!�
!�	)�Z�+�J�
�39�;�;�;�K�&�.�{�D�I�I�I�M�!0��Z��!W�!W��H�h����x�(�(�(�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)�	)����	)�	)�	)�	)�	)�	)s�AA:�:A>�A>c�(�tj��5}tj�|d��}t|��t
|d��}t|dd��}|�|��ddd��dS#1swxYwYdS)N�test_pkgr
�launchztest_pkg.check_sibling)	rrJrZr&�joinrrr'rF)r.r�pkg_dirr6�launch_names     r�test_module_in_packagez2MultiProcessingCmdLineMixin.test_module_in_package�s���
�
�
!�
!�	,�Z��g�l�l�:�z�:�:�G��W����+�G�_�E�E�K�-�j�(�.F�H�H�K����{�+�+�+�
	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�A&B�B�Bc���tj��5}t|ddd��\}}t|dd|��}|�|��ddd��dS#1swxYwYdS)NrfrnrHroztest_pkg.script�rrJr!r'rF�r.rrgrhrrs     r�!test_module_in_package_in_zipfilez=MultiProcessingCmdLineMixin.test_module_in_package_in_zipfile�s���
�
�
!�
!�	,�Z�!3�J�
�J�X`�!a�!a��H�h�-�j�(�DU�W_�`�`�K����{�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�=A�A"�%A"c���tj��5}t|dddd���\}}t|dd|��}|�|��ddd��dS#1swxYwYdS)NrfrnrH�)r roztest_pkg.test_pkg.scriptrurvs     r�$test_module_in_subpackage_in_zipfilez@MultiProcessingCmdLineMixin.test_module_in_subpackage_in_zipfile�s���
�
�
!�
!�	,�Z�!3�J�
�J�X`�hi�!j�!j�!j��H�h�-�j�(�D^�`h�i�i�K����{�+�+�+�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�?A � A$�'A$c�:�|j}tj��5}tj�|d��}t
|��t|d|���}t|dd��}|�	|��ddd��dS#1swxYwYdS)Nrnr`rQro)
rarrJrZr&rprrr'rF)r.rrrqr6rrs      r�test_packagez(MultiProcessingCmdLineMixin.test_packages����-��
�
�
!�
!�	,�Z��g�l�l�:�z�:�:�G��W����+�G�Z�39�;�;�;�K�-�j�(�J�O�O�K����{�+�+�+�
	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,�	,����	,�	,�	,�	,�	,�	,s�A(B�B�Bc��|j}tj��5}tj�|d��}t
|��t|d|���}tj	|d���}tj
|��tj|��}t|dd��}|�|��ddd��dS#1swxYwYdS)Nrnr`rQTrVro)rarrJrZr&rprrrXrYr[rr\r'rF)r.rrrqr6rkr]rrs        r�test_package_compiledz1MultiProcessingCmdLineMixin.test_package_compileds���-��
�
�
!�
!�		,�Z��g�l�l�:�z�:�:�G��W����+�G�Z�39�;�;�;�K�&�.�{�D�I�I�I�M��I�k�"�"�"�$�4�[�A�A�H�-�j�(�J�O�O�K����{�+�+�+�		,�		,�		,�		,�		,�		,�		,�		,�		,�		,�		,�		,����		,�		,�		,�		,�		,�		,s�B&C�C�C)�__name__�
__module__�__qualname__�maxDiffr/r;rFrLrNrTr^rbrdrirlrsrwrzr|r~�rrr)r)�s�������G�O�O�O�H�H�H�6�6�6�,�,�,�
,�,�,�
1�
1�
1�)�)�)�+�+�+�+�+�+�)�)�)�)�)�)�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,rr)c��eZdZdZeZdS)�SpawnCmdLineTest�spawnN�rr�r�r+rRrar�rrr�r�s�������L�B���rr�c��eZdZdZeZdS)�ForkCmdLineTest�forkN)rr�r�r+�test_sourcerar�rrr�r�!s�������L�)���rr�c��eZdZdZeZdS)�ForkServerCmdLineTest�
forkserverNr�r�rrr�r�%s�������L�B���rr�c�,�tj��dSr)r�
reap_childrenr�rr�tearDownModuler�)s��������rr`r))�testr�test.supportr�
import_moduler�importlib.machinery�unittestr@rZ�os.pathrXr�test.support.script_helperrrr	r
r�PGO�SkipTest�multiprocessing�set�get_all_start_methodsr,�*skip_if_broken_multiprocessing_synchronizer1r�rRrr!r$r'r)�TestCaser�r�r�r�r�mainr�rr�<module>r�s���������&�&�&�&�&�&��
��.�/�/�/�������������
�
�
�
�	�	�	�	���������"�"�"�"�"�"����������������;�;�
�(�
�9�
:�
:�:������#�C�o�C�E�E�F�F��3��2�4�4�4�
�/��*��X(�$�H)�e�����*�������
�����E,�E,�E,�E,�E,�E,�E,�E,�RC�C�C�C�C�2�H�4E�C�C�C�*�*�*�*�*�1�8�3D�*�*�*�C�C�C�C�C�7��9J�C�C�C�����z����H�M�O�O�O�O�O��r