
    =Og%                        d dl Z d dlZd dlZd dlZddlmZmZ ddlmZ ddlm	Z	 ddlm
Z
 g dZej        dk    rd	Zd	Zn@ eed
d	          Zej        o+ej                                                            d          Zd Zd Zer* ee j                            ej        d                     n eej                   d Zd Zd ZddZd Zd Zd Zg Zd Z d Z!d Z"d Z#dS )    N   )get_start_methodset_start_method)process)	reduction)util)_mainfreeze_supportset_executableget_executableget_preparation_dataget_command_lineimport_main_pathwin32Ffrozenzpythonservice.exec                     | | a d S t          j        dk    rt          j        |           a d S t          j        |           a d S )Nr   )_python_exesysplatformosfsdecodefsencode)exes    ./usr/lib64/python3.11/multiprocessing/spawn.pyr   r   $   sC    
{		 	 k#&&k#&&    c                      t           S N)r    r   r   r   r   -   s    r   z
python.exec                 J    	 t          |           dk    r| d         dk    rdS dS )N   r   --multiprocessing-forkTF)len)argvs    r   
is_forkingr$   9   s1     4yyA~~$q'%===tur   c                     	 t          t          j                  rpi } t          j        dd          D ]8}|                    d          \  }}|dk    rd | |<   &t	          |          | |<   9t          di |  t          j                     d S d S )Nr    =Noner   )r$   r   r#   splitint
spawn_mainexit)kwdsargnamevalues       r   r
   r
   C   s     #( 	8ABB< 	( 	(C))C..KD%!T

 ZZT

T




	 	r   c                  P   	 t          t          dd          r-t          j        dgd |                                 D             z   S d}|d                    d |                                 D                       z  }t          j                    }t                      }|g|z   d|dgz   S )	Nr   Fr!   c                     g | ]}d |z  S )%s=%rr   .0items     r   
<listcomp>z$get_command_line.<locals>.<listcomp>Y   s    999D4999r   z<from multiprocessing.spawn import spawn_main; spawn_main(%s)z, c              3       K   | ]	}d |z  V  
dS )r2   Nr   r3   s     r   	<genexpr>z#get_command_line.<locals>.<genexpr>\   s&      BBT'D.BBBBBBr   z-c)getattrr   
executableitemsjoinr   _args_from_interpreter_flagsr   )r,   progoptsr   s       r   r   r   S   s     sHe$$ E!9:99DJJLL999: 	; N		BBTZZ\\BBBBBB022ut|tT+CDDDr   c                    	 t           j        dk    rjdd l}dd l}|%|                    |j        |j        z  d|          }nd }t          j        | |          }|	                    |t          j                  }|}n(ddlm}	 ||	j        _        | }t          j        |           }t#          ||          }
t          j        |
           d S )Nr   r   F)source_processr   )resource_tracker)r   r   msvcrt_winapiOpenProcessSYNCHRONIZEPROCESS_DUP_HANDLEr   	duplicateopen_osfhandler   O_RDONLY rB   _resource_tracker_fddupr	   r+   )pipe_handle
parent_pid
tracker_fdrC   rD   rA   
new_handlefdparent_sentinelrB   exitcodes              r   r*   r*   b   s     |w!$00#g&@@z# #NN "N(8FH H H
"":r{;;(&&&&&&1;*.&--R))HHXr   c                    t          j        | dd          5 }dt          j                    _        	 t
          j                            |          }t          |           t
          j                            |          }t          j                    `n# t          j                    `w xY w	 d d d            n# 1 swxY w Y   |	                    |          S )NrbT)closefd)
r   fdopenr   current_process_inheritingr   pickleloadprepare
_bootstrap)rS   rT   from_parentpreparation_dataselfs        r   r	   r	   ~   s   	2tT	*	*	* 6k04!!-	6(/44[AA$%%%#((55D'))55'))5555556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 ???+++s)   B8AB?B8B((B88B<?B<c                  h    t          t          j                    dd          rt          d          d S )Nr[   Fa  
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

        To fix this issue, refer to the "Safe importing of main module"
        section in https://docs.python.org/3/library/multiprocessing.html
        )r9   r   rZ   RuntimeErrorr   r   r   _check_not_importing_mainre      s@    w&((-??     	 r   c           	         	 t                       t          t          j        t	          j                    j                  }t          j        !t          j                                        |d<   t          j
                                        }	 |                    d          }t          j        ||<   n# t          $ r Y nw xY w|                    | |t          j        t          j        t#          j                    t'                                 t          j        d         }t+          |j        dd           }|||d<   nt          j        dk    st0          st2          st+          |d	d           }|wt"          j
                            |          s6t          j        *t"          j
                            t          j        |          }t"          j
                            |          |d
<   |S )N)log_to_stderrauthkey	log_levelrK   )r.   sys_pathsys_argvorig_dirdirstart_method__main__r.   init_main_from_namer   __file__init_main_from_path)re   dictr   _log_to_stderrr   rZ   rh   _loggergetEffectiveLevelr   pathcopyindexORIGINAL_DIR
ValueErrorupdater#   r   getcwdr   modulesr9   __spec__r   WINEXE
WINSERVICEisabsr<   normpath)r.   drj   imain_modulemain_mod_name	main_paths          r   r   r      s    )'))1	
 	
 	
A
 |7799+X]]__H+NN2 *    
 HH%IKK%''  
 
 
 +j)KK0&$??M #0
  		 	 	 
	 KT::	 GMM),, J,8GLL)=yII	')w'7'7	'B'BA#$Hs   B2 2
B?>B?c                    	 d| v r| d         t          j                    _        d| v r| d         t          j                    _        d| v r| d         rt	          j                     d| v r,t	          j                                        | d                    d| v r| d         t          _	        d| v r| d         t          _
        d| v rt          j        | d                    d| v r| d         t           _        d	| v rt          | d	         d
           d| v rt          | d                    d S d| v rt!          | d                    d S d S )Nr.   rh   rg   ri   rj   rk   rm   rl   rn   T)forcerp   rr   )r   rZ   r.   rh   r   rg   
get_loggersetLevelr   rw   r#   r   chdirrz   r   _fixup_main_from_name_fixup_main_from_path)datas    r   r^   r^      so    ~~)-f!!&D,0O!!)$4#8d""4#4555T
#T
#}}
eT#J/n-T::::$$d#89:::::	$	&	&d#89::::: 
'	&r   c                    t           j        d         }| dk    s|                     d          rd S t          |j        dd           | k    rd S t
                              |           t          j        d          }t          j
        | dd          }|j                            |           |xt           j        d<   t           j        d<   d S )Nro   z	.__main__r.   __mp_main__T)run_name	alter_sys)r   r~   endswithr9   r   old_main_modulesappendtypes
ModuleTyperunpy
run_module__dict__r|   )mod_namecurrent_mainr   main_contents       r   r   r      s    
 ;z*L:!2!2;!?!? |$fd33x??
 L)))"=11K#H-:.24 4 4L ---;FFCK
ck-888r   c                    t           j        d         }t          j                            t          j                            |                     d         }|dk    rd S t          |dd           | k    rd S t                              |           t          j
        d          }t          j        | d          }|j                            |           |xt           j        d<   t           j        d<   d S )Nro   r   ipythonrq   r   )r   )r   r~   r   rw   splitextbasenamer9   r   r   r   r   r   run_pathr   r|   )r   r   	main_namer   r   s        r   r   r     s    ;z*L   !1!1)!<!<==a@II |Z..);;
 L)))"=11K>)+8: : :L---;FFCK
ck-888r   c                 &    	 t          |            d S r   )r   )r   s    r   r   r   /  s     )$$$$$r   )NN)$r   r   r   r   rK   r   r   r   contextr   r   __all__r   r   r   r9   r:   lowerr   r   r   rw   r<   exec_prefixr$   r
   r   r*   r	   re   r   r   r^   r   r   r   r   r   r   <module>r      s
   
			 



   0 0 0 0 0 0 0 0                  K K K <7FJJWS(E**FXCN$8$8$:$:$C$CDW$X$XJ' ' '    #N27<<>>????N3>"""     E E E   8	, 	, 	,  ,, , ,d  "; "; ";LG G G2G G G8% % % % %r   