3 \"@s.ddlZddlZddlZddlZddlmZmZddlmZddlm Z ddlm Z ddd d d d d gZ ej dkrzdZ dZn&ej dkoeeddZ ejjjdZerejjejdanejadd 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|adS)N) _python_exe)Zexer/usr/lib64/python3.6/spawn.pyr )scCstS)N)rrrrrr -scCs$t|dkr|ddkrdSdSdS)z= Return whether commandline indicates we are forking rz--multiprocessing-forkTFN)len)argvrrr is_forking4srcCshttjrdi}xBtjddD]0}|jd\}}|dkrBd||<qt|||<qWtf|tjdS)zE Run code for process object if this in not the main process rN=None)rsysrsplitint spawn_mainexit)kwdsargnamevaluerrrr >s   cKshttddr(tjdgdd|jDSd}|djdd |jD;}tj}tg|d |dgSd S) zJ Returns prefix of command line used for spawning a child process rFz--multiprocessing-forkcSsg|] }d|qS)z%s=%rr).0itemrrr Tsz$get_command_line..zWsz#get_command_line..z-cN)getattrr executableitemsjoinrZ_args_from_interpreter_flagsr)rprogZoptsrrrr Ns cCs\tjdkr.ddl}tj||}|j|tj}nddlm }||j _ |}t |}tj |dS)z7 Run code specified by data received over pipe rrNr)semaphore_tracker)rplatformmsvcrtrZ steal_handleZopen_osfhandleosO_RDONLYr,Z_semaphore_trackerZ_fdrr)Z pipe_handleZ parent_pidZ tracker_fdr.Z new_handlefdr,Zexitcoderrrr\s   rcCs^tj|ddd@}dtj_z$tjj|}t|tjj|}Wdtj`XWdQRX|j S)NrbT)closefd) r/fdopenrcurrent_process _inheritingrpickleloadprepare _bootstrap)r2Z from_parentZpreparation_dataselfrrrrms  cCsttjddrtddS)Nr7Fa 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'rr6 RuntimeErrorrrrr_check_not_importing_mainys r>cCs tttjtjjd}tjdk r2tjj|d<t j j }y|j d}Wnt k r^Yn Xtj||<|j||t jtjtjtdt jd}t|jdd}|dk r||d<nht jd kst ot rt|d d}|dk rtj j| otjdk r tj jtj|}tj j||d <|S) zM Return info about parent needed by child to unpickle process object ) log_to_stderrauthkeyN log_levelr1)r!sys_pathsys_argvorig_dirdir start_method__main__r!init_main_from_namer__file__init_main_from_path)r>dictrZ_log_to_stderrrr6r@Z_loggerZgetEffectiveLevelrpathcopyindex ValueError ORIGINAL_DIRupdaterr/getcwdrmodulesr'__spec__r-WINEXE WINSERVICEisabsr*normpath)r!drBi main_moduleZ main_mod_name main_pathrrrr s>         cCsd|kr|dtj_d|kr,|dtj_d|krD|drDtjd|kr^tjj|dd|krp|dt_ d|kr|dt_ d|krt j |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!r@r?rArBrCrErDrFT)forcerHrJN)rr6r!r@rr?Z get_loggerZsetLevelrrLrr/chdirrPr_fixup_main_from_name_fixup_main_from_path)datarrrr:s,   r:cCs~tjd}|dks|jdr dSt|jdd|kr6dStj|tjd}t j |ddd}|j j ||tjd<tjd<dS)NrGz .__main__r! __mp_main__T)run_nameZ alter_sys) rrSendswithr'rTold_main_modulesappendtypes ModuleTyperunpyZ run_module__dict__rQ)Zmod_name current_mainr[ main_contentrrrr_s    r_cCstjd}tjjtjj|d}|dkr.dSt|dd|krBdStj|t j d}t j |dd}|j j||tjd<tjd<dS)NrGrZipythonrIrb)rc)rrSr/rLsplitextbasenamer'rerfrgrhriZrun_pathrjrQ)r\rkZ main_namer[rlrrrr`s    r`cCs t|dS)z< Set sys.modules['__main__'] to module at main_path N)r`)r\rrrrs)NN)%r/rrirgr1rrrcontextrr__all__r-rUrVr'r(lowerrdrLr* exec_prefixrr r rr r rrr>r rer:r_r`rrrrr s>        2&