[# @sydddgZddlZddlZddlZddlZddlmZyejjej Z Wne k rdZ YnXddZ ddZ dd ZGd ddeZGd d d eZGd ddeZeaejdaea[iZxSeejjD]<\ZZedddkr,dekr,eee Ssz'BaseProcess.__init__..)AssertionErrornext_process_counterr _identity_configcopyosgetpid _parent_pidr _targettuple_argsdict_kwargstype__name__join_namer _danglingadd)rgrouptargetnameargskwargsrcountrrr__init__Gs   #  zBaseProcess.__init__cCs&|jr"|j|j|jndS)zQ Method to be run in sub-process; can be overridden in sub-class N)r#r%r')rrrrrunXs zBaseProcess.runcCs|jdkstd|jtjks<tdtjjd s[tdt|j ||_|jj |_ t j |dS)z% Start child process Nzcannot start a process twicez:can only start a process object created by current processrz3daemonic processes are not allowed to have children)r rr"r r!rrgetr rsentinel _sentinelr r-)rrrrstart_s  zBaseProcess.startcCs|jjdS)zT Terminate process; sends SIGTERM signal or uses TerminateProcess() N)r terminate)rrrrr:mszBaseProcess.terminatecCsn|jtjks!td|jdk s<td|jj|}|dk rjtj|ndS)z5 Wait until child process terminates zcan only join a child processNzcan only join a started process)r"r r!rr waitr r)rZtimeoutZresrrrr*ss ! zBaseProcess.joincCsa|tkrdS|jtjks1td|jdkrDdS|jj|jjdkS)z1 Return whether process is alive Tzcan only test a child processNF)rr"r r!rr r returncode)rrrris_alive}s ! zBaseProcess.is_alivecCs|jS)N)r+)rrrrr0szBaseProcess.namecCs(t|tstd||_dS)Nzname must be a string) isinstancerrr+)rr0rrrr0scCs|jjddS)z4 Return whether process is a daemon rF)rr6)rrrrrszBaseProcess.daemoncCs,|jdkstd||jdz daemon)rr"r r!r r rAr(int_exitcode_to_namer6r)r+r)rZstatusrrr__repr__s       zBaseProcess.__repr__c(Csddlm}m}zy|jdk r>|j|jntjdata t j dk ry#t j j t tjt _ Wqttfk rYqXnt}|az|jj|jWd~X|jdz|jd}Wd|jXWntk r}zd|js+d}nMt|jdtrQ|jd}n't jjt|jddd}WYdd}~Xn;d}ddl }t jjd|j!|j"YnXWd|jd|t j#j$t jj$X|S)N)utilcontextz child process calling self.run()r z Process %s: z process exiting with exitcode %d)%rHrMrNZ _start_methodZ_force_start_method itertoolsr3rsetr sysstdincloseopenr devnullOSErrorrErZ_finalizer_registryclearZ_run_after_forkersinfor5Z_exit_function SystemExitr1r>rIstderrwriter tracebackr0 print_excstdoutflush)rrMrNZ old_processrAer]rrr _bootstrapsN        !  zBaseProcess._bootstrap)r) __module__ __qualname____doc__rr4r5r9r:r*r=propertyr0setterrr?rArCrBr7rKrbrrrrr>s*         c@seZdZddZdS)r@cCsAddlm}|dkr.tdntt|ffS)NrL)get_spawning_popenzJPickling an AuthenticationString object is disallowed for security reasons)rNrh TypeErrorr@bytes)rrhrrr __reduce__s  zAuthenticationString.__reduce__N)r)rcrdrkrrrrr@s r@c@seZdZddZdS) _MainProcesscCsNf|_d|_d|_d|_ittjdd6dd6|_dS)NZ MainProcess r?z/mpZ semprefix)rr+r"r r@r urandomr)rrrrr4*s     z_MainProcess.__init__N)r)rcrdr4rrrrrl(s rlrLZSIG_) __all__r rRsignalrP _weakrefsetrpathabspathgetcwdZ ORIGINAL_DIRrWrrr objectrrjr@rlrr3rrQr rJr __dict__itemsr0Zsignumr,rrrr s0          ""