U e5dP$@s$ddlZddlZddlZddlZddlmZmZddlmZddlm Z ddlm Z ddd d d d d gZ ej dkrzdZ dZneeddZ ejdZerejejdanejadd Zdd ZddZddZdd Zd&ddZddZddZdd ZgZ dd Z!d!d"Z"d#d$Z#d%d Z$dS)'N)get_start_methodset_start_method)process) reduction)util_mainfreeze_supportset_executableget_executableget_preparation_dataget_command_lineimport_main_pathwin32Ffrozenzpythonservice.exez python.execCs|adSN _python_exe)Zexer-/usr/lib64/python3.8/multiprocessing/spawn.pyr )scCstSrrrrrrr -scCs$t|dkr|ddkrdSdSdS)Nr--multiprocessing-forkTF)len)argvrrr is_forking4srcCsdttjr`i}tjddD]0}|d\}}|dkr@d||<qt|||<qtf|tdS)Nr=None)rsysrsplitint spawn_mainexit)kwdsargnamevaluerrrr >s   cKshttddr(tjdgdd|DSd}|ddd |D;}t}tg|d |dgSdS) NrFrcSsg|] }d|qS)%s=%rr.0itemrrr Tsz$get_command_line..zWsz#get_command_line..z-c)getattrr executableitemsjoinrZ_args_from_interpreter_flagsr)r"progZoptsrrrr Ns c Cstjdkr`ddl}ddl}|dk r:||j|jBd|}nd}tj||d}| |t j }|}n"ddl m } || j_|}t |}t||} t| dS)NrrF)source_processr)resource_tracker)rplatformmsvcrt_winapiZ OpenProcessZ SYNCHRONIZEZPROCESS_DUP_HANDLErZ duplicateZopen_osfhandleosO_RDONLYr2Z_resource_trackerZ_fdduprr!) Z pipe_handleZ parent_pidZ tracker_fdr4r5r1Z new_handlefdparent_sentinelr2Zexitcoderrrr \s*     r c Cs`tj|ddd@}dt_z$tj|}t|tj|}W5t`XW5QRX| |S)NrbT)closefd) r6fdopenrcurrent_process _inheritingrpickleloadprepare _bootstrap)r:r;Z from_parentZpreparation_dataselfrrrrxs  cCsttddrtddS)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.)r,rr? RuntimeErrorrrrr_check_not_importing_mainsrGcCstttjtjd}tjdk r2tj|d<t j }z| d}Wnt k r^Yn Xtj||<|j||t jtjttdt jd}t|jdd}|dk r||d<nft jdkststst|d d}|dk rtj |s tjdk r tj tj|}tj ||d <|S) N) log_to_stderrauthkey log_levelr8)r$sys_pathsys_argvorig_dirdir start_method__main__r$init_main_from_namer__file__init_main_from_path)rGdictrZ_log_to_stderrrr?rIZ_loggerZgetEffectiveLevelrpathcopyindex ValueError ORIGINAL_DIRupdaterr6getcwdrmodulesr,__spec__r3WINEXE WINSERVICEisabsr/normpath)r$drKi main_moduleZ main_mod_name main_pathrrrr sD       cCsd|kr|dt_d|kr,|dt_d|krD|drDtd|kr^t|dd|krp|dt_ d|kr|dt_ d|krt |dd|kr|dt_ d |krt|d d d d |krt|d nd |krt|d dS)Nr$rIrHrJrKrLrNrMrOT)ZforcerQrS)rr?r$rIrrHZ get_loggerZsetLevelrrUrr6chdirrYr_fixup_main_from_name_fixup_main_from_path)datarrrrCs,   rCcCs~tjd}|dks|dr dSt|jdd|kr6dSt|td}t j |ddd}|j ||tjd<tjd<dS)NrPz .__main__r$ __mp_main__T)run_nameZ alter_sys) rr\endswithr,r]old_main_modulesappendtypes ModuleTyperunpyZ run_module__dict__rZ)Zmod_name current_mainrd main_contentrrrrgs    rgcCstjd}tjtj|d}|dkr.dSt|dd|krBdSt|t d}t j |dd}|j ||tjd<tjd<dS)NrPrZipythonrRrj)rk)rr\r6rUsplitextbasenamer,rmrnrorprqZrun_pathrrrZ)rersZ main_namerdrtrrrrh s    rhcCs t|dSr)rh)rerrrr%s)NN)%r6rrqror8rrrcontextrr__all__r3r^r_r,r-lowerrlrUr/ exec_prefixrr r rr r r rrGr rmrCrgrhrrrrr sD        2&