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)z= Return whether commandline indicates we are forking r--multiprocessing-forkTFN)len)argvrrr is_forking4srcCsdttjr`i}tjddD]0}|d\}}|dkr@d||<qt|||<qtf|tdS)zE Run code for process object if this in not the main process rN=None)rsysrsplitint spawn_mainexit)kwdsargnamevaluerrrr >s   cKshttddr(tjdgdd|DSd}|ddd |D;}t}tg|d |dgSd S) zJ Returns prefix of command line used for spawning a child process rFrcSsg|] }d|qS)%s=%rr.0itemrrr Tsz$get_command_line..zWsz#get_command_line..z-cN)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)z7 Run code specified by data received over pipe rrNF)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 jd kststst|d d}|dk rtj |s tjdk r tj tj|}tj ||d <|S) zM Return info about parent needed by child to unpickle process object ) log_to_stderrauthkeyN 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)zE Try to get current process ready to unpickle process object r$rIrHrJrKrLrNrMrOT)ZforcerQrSN)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|dS)z< Set sys.modules['__main__'] to module at main_path N)rh)rerrrr%s)NN)%r6rrqror8rrrcontextrr__all__r3r^r_r,r-lowerrlrUr/ exec_prefixrr r rr r r rrGr rmrCrgrhrrrrr sD        2&