+
    Bi-                     ^   ^ RI Ht ^ RIHt ]P                  ! R4       ^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t	^ RIt^ RIHt ^ RIHtHtHtHtHt ]P&                  '       d   ]P(                  ! R4      h^ RIt]! ]P.                  ! 4       4      t]P2                  ! 4        ]P4                  tRtR	t]R
3R lt]^3R ltRtRR lt  ! R R4      t! ! R R]!]PD                  4      t# ! R R]!]PD                  4      t$ ! R R]!]PD                  4      t%R t&]'R8X  d   ]PP                  ! 4        R# R# )    )support)import_helper_multiprocessingN)	os_helper)make_pkgmake_scriptmake_zip_pkgmake_zip_scriptassert_python_okztest 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                 p    \        WW#4      pVR 8X  d   \        V RR4       \        P                  ! 4        V# )check_siblingsibling )r   	importlibinvalidate_caches)
script_dirscript_basenamesourceomit_suffix	to_returns   &&&& >/usr/lib/python3.14/test/test_multiprocessing_main_handling.py_make_test_scriptr   n   s9    J"1I /)J	2.!    c                 J    \        WW#WE4      p\        P                  ! 4        V# N)r	   r   r   )zip_dirzip_basenamepkg_namer   r   depthr   s   &&&&&& r   _make_test_zip_pkgr    x   s%    WH#,I!r   zPimport sys, os.path, runpy
sys.path.insert(0, %s)
runpy._run_module_as_main(%r)
c                     Vf   RpM\        V4      p\        W23,          p\        WV4      p\        P                  ! 4        V# )Nzos.path.dirname(__file__))reprlaunch_sourcer   r   r   )r   r   module_namepathr   r   s   &&&&  r   _make_launch_scriptr&      s@    |*Dzd00FJ@I!r   c                      a  ] tR t^t o RtR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tR tR tR tR tRtV tR# )MultiProcessingCmdLineMixinNc                x    V P                   \        9  d%   V P                  R V P                   ,          4       R# R# )z%r start method not availableN)start_methodAVAILABLE_START_METHODSskipTest)selfs   &r   setUp!MultiProcessingCmdLineMixin.setUp   s.    $;;MM9D<M<MMN <r   c                R   \         ^8  d'   \        RV,          4       \        \        V4      4       V P                  V^ 4       V P                  VP	                  R4      R4       RV P
                  ,          pV P                  VP	                  R4      P                  4       V4       R# )   zOutput from test script %r:zutf-8r   z%s -> [1, 4, 9]N)verboseprintr"   assertEqualdecoder*   strip)r-   script_name	exit_codeouterrexpected_resultss   &&&&& r   _check_output)MultiProcessingCmdLineMixin._check_output   s    Q;/+=>$s)A&G,b1,t/@/@@G,2246FGr   c                     VRR\         P                  P                  ,          ,           3,          pW!V P                  3,           p\	        VRR / w  rEpV P                  WWV4       R# )F-O
__isolatedN)sysflagsoptimizer*   r   r<   )r-   r7   cmd_line_switchesrun_argsrcr9   r:   s   &&*    r   _check_script)MultiProcessingCmdLineMixin._check_script   s]    #cii.@.@(@"@!BB$T5F5F'GG'DeD;C5r   c                    \         P                  ! 4       ;_uu_ 4       p\        VR 4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)scriptNr   temp_dirr   rH   r-   r   r7   s   &  r   test_basic_script-MultiProcessingCmdLineMixin.test_basic_script   s<    !!Z+JAK{+ "!!!s   AA	c                    \         P                  ! 4       ;_uu_ 4       p\        VR RR7      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)rK   T)r   NrL   rN   s   &  r   test_basic_script_no_suffix7MultiProcessingCmdLineMixin.test_basic_script_no_suffix   sA    !!Z+J8<>K{+ "!!!s    AA	c           	        \         p\        P                  ! 4       ;_uu_ 4       p\        VR VR7      pV P	                  V4       \        VR VRR7      pV P	                  V4       RRR4       R#   + '       g   i     R# ; i)ipythonr   T)r   r   N)$test_source_main_skipped_in_childrenr   rM   r   rH   )r-   r   r   r7   script_no_suffixs   &    r   test_ipython_workaround3MultiProcessingCmdLineMixin.test_ipython_workaround   so    
 6!!Z+J	39;K{+0Y8>=A C /0 "!!!s   A A..A?	c                <   \         P                  ! 4       ;_uu_ 4       p\        VR 4      p\        P                  ! VRR7       \
        P                  ! V4       \        P                  ! V4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)rK   TdoraiseN)
r   rM   r   
py_compilecompileosremover   make_legacy_pycrH   )r-   r   r7   pyc_files   &   r   test_script_compiled0MultiProcessingCmdLineMixin.test_script_compiled   sh    !!Z+JAK{D9IIk"$44[AHx( "!!!s   A"B

B	c                    V P                   p\        P                  ! 4       ;_uu_ 4       p\        VR VR7      pV P	                  V4       RRR4       R#   + '       g   i     R# ; i)__main__rV   N)main_in_children_sourcer   rM   r   rH   )r-   r   r   r7   s   &   r   test_directory*MultiProcessingCmdLineMixin.test_directory   sL    --!!Z+J
39;Kz* "!!!s    AA%	c                X   V P                   p\        P                  ! 4       ;_uu_ 4       p\        VR VR7      p\        P
                  ! VRR7       \        P                  ! V4       \        P                  ! V4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)rg   rV   Tr\   N)rh   r   rM   r   r^   r_   r`   ra   r   rb   rH   )r-   r   r   r7   rc   s   &    r   test_directory_compiled3MultiProcessingCmdLineMixin.test_directory_compiled   sx    --!!Z+J
39;K{D9IIk"$44[AHz* "!!!s   A$BB)	c                    V P                   p\        P                  ! 4       ;_uu_ 4       p\        VR VR7      p\	        VRV4      w  rEV P                  V4       RRR4       R#   + '       g   i     R# ; i)rg   rV   test_zipN)rh   r   rM   r   r
   rH   )r-   r   r   r7   zip_namerun_names   &     r   test_zipfile(MultiProcessingCmdLineMixin.test_zipfile   s]    --!!Z+J
39;K!0Z!UHx(	 "!!!s   /A##A4	c                   V P                   p\        P                  ! 4       ;_uu_ 4       p\        VR VR7      p\        P
                  ! VRR7      p\        VRV4      w  rVV P                  V4       RRR4       R#   + '       g   i     R# ; i)rg   rV   Tr\   ro   N)rh   r   rM   r   r^   r_   r
   rH   )r-   r   r   r7   compiled_namerp   rq   s   &      r   test_zipfile_compiled1MultiProcessingCmdLineMixin.test_zipfile_compiled   so    --!!Z+J
39;K&..{DIM!0Z!WHx( "!!!s   AA;;B	c                $   \         P                  ! 4       ;_uu_ 4       p\        P                  P	                  VR 4      p\        V4       \        VR4      p\        VRR4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)test_pkgr   launchztest_pkg.check_siblingN)	r   rM   r`   r%   joinr   r   r&   rH   )r-   r   pkg_dirr7   launch_names   &    r   test_module_in_package2MultiProcessingCmdLineMixin.test_module_in_package   sj    !!Zggll:z:GW+G_EK-j(.FHK{+ "!!!s   AA>>B	c                    \         P                  ! 4       ;_uu_ 4       p\        VR RR4      w  r#\        VRRV4      pV P	                  V4       RRR4       R#   + '       g   i     R# ; i)ro   ry   rK   rz   ztest_pkg.scriptNr   rM   r    r&   rH   r-   r   rp   rq   r}   s   &    r   !test_module_in_package_in_zipfile=MultiProcessingCmdLineMixin.test_module_in_package_in_zipfile   sV    !!Z!3J
JX`!aH-j(DUW_`K{+ "!!!s   0AA)	c           
         \         P                  ! 4       ;_uu_ 4       p\        VR RR^R7      w  r#\        VRRV4      pV P	                  V4       RRR4       R#   + '       g   i     R# ; i)ro   ry   rK   )r   rz   ztest_pkg.test_pkg.scriptNr   r   s   &    r   $test_module_in_subpackage_in_zipfile@MultiProcessingCmdLineMixin.test_module_in_subpackage_in_zipfile   sY    !!Z!3J
JX`hi!jH-j(D^`hiK{+ "!!!s   2AA+	c                @   V P                   p\        P                  ! 4       ;_uu_ 4       p\        P                  P                  VR 4      p\        V4       \        VRVR7      p\        VRR 4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)ry   rg   rV   rz   N)
rh   r   rM   r`   r%   r{   r   r   r&   rH   )r-   r   r   r|   r7   r}   s   &     r   test_package(MultiProcessingCmdLineMixin.test_package  sv    --!!Zggll:z:GW+GZ39;K-j(JOK{+ "!!!s   ABB	c                   V P                   p\        P                  ! 4       ;_uu_ 4       p\        P                  P                  VR 4      p\        V4       \        VRVR7      p\        P                  ! VRR7      p\        P                  ! V4       \        P                  ! V4      p\        VRR 4      pV P                  V4       RRR4       R#   + '       g   i     R# ; i)ry   rg   rV   Tr\   rz   N)rh   r   rM   r`   r%   r{   r   r   r^   r_   ra   r   rb   r&   rH   )r-   r   r   r|   r7   ru   rc   r}   s   &       r   test_package_compiled1MultiProcessingCmdLineMixin.test_package_compiled  s    --!!Zggll:z:GW+GZ39;K&..{DIMIIk"$44[AH-j(JOK{+ "!!!s   BCC!	 )__name__
__module____qualname____firstlineno__maxDiffr.   r<   rH   rO   rR   rY   rd   ri   rl   rr   rv   r~   r   r   r   r   __static_attributes____classdictcell__)__classdict__s   @r   r(   r(      sa     GOH6,
,1)++)),,,,, ,r   r(   c                       ] tR tRtRt]tRtR# )SpawnCmdLineTesti  spawnr   Nr   r   r   r   r*   rW   rh   r   r   r   r   r   r     s    LBr   r   c                       ] tR tRtRt]tRtR# )ForkCmdLineTesti   forkr   N)r   r   r   r   r*   test_sourcerh   r   r   r   r   r   r      s    L)r   r   c                       ] tR tRtRt]tRtR# )ForkServerCmdLineTesti$  
forkserverr   Nr   r   r   r   r   r   $  s    LBr   r   c                  0    \         P                  ! 4        R # r   )r   reap_childrenr   r   r   tearDownModuler   (  s    r   rg   r   ))testr   test.supportr   import_moduler   importlib.machineryunittestrB   r`   os.pathr^   r   test.support.script_helperr   r   r	   r
   r   PGOSkipTestmultiprocessingsetget_all_start_methodsr+   *skip_if_broken_multiprocessing_synchronizer2   r   rW   r   r    r#   r&   r(   TestCaser   r   r   r   r   mainr   r   r   <module>r      s+    &   . /    
 	   "  ;;;


9
:: oCCEF   2 2 4
//*X( $F )e *E, E,RC2H4E4E C*183D3D *C79J9J C zMMO r   