U e5d.@s8ddddgZddlZddlZddlZddlZddlZddlmZzej e Z Wne k rldZ YnXddZ ddZd dZd d ZGd ddeZGd ddeZGdddeZGdddeZdaeaedaea[iZeej D]0\Z!Z"e!dddkrde!krde!ee" <qeZ#dS) BaseProcesscurrent_processactive_childrenparent_processN)WeakSetcCstSN)_current_processr r //usr/lib64/python3.8/multiprocessing/process.pyr%scCstttSr)_cleanuplist _childrenr r r r r+scCstSr)_parent_processr r r r r3scCs*ttD]}|jdk rt|qdSr)r r _popenpolldiscard)pr r r r =s r c@seZdZddZddddifddddZdd Zd d Zd d ZddZddZ d+ddZ ddZ ddZ e ddZejddZe ddZejddZe ddZejd dZe d!d"Ze d#d$ZeZe d%d&Zd'd(Zd,d)d*ZdS)-rcCstdSr)NotImplementedErrorselfr r r _PopenMszBaseProcess._PopenNr )daemoncCstt}tj|f|_tj|_t|_tj |_ d|_ d|_ ||_ t||_t||_|pt|jdddd|jD|_|dk r||_t|dS)NF-:css|]}t|VqdSr)str).0ir r r ^sz'BaseProcess.__init__..)next_process_counterr _identity_configcopyosgetpid _parent_pidname _parent_namer_closed_targettuple_argsdict_kwargstype__name__join_namer _danglingadd)rgrouptargetr&argskwargsrcountr r r __init__Ps     zBaseProcess.__init__cCs|jrtddS)Nzprocess object is closed)r( ValueErrorrr r r _check_closedcszBaseProcess._check_closedcCs|jr|j|j|jdSr)r)r+r-rr r r rungszBaseProcess.runcCs>|t|||_|jj|_|`|`|`t |dSr) r;r rrsentinel _sentinelr)r+r-r r3rr r r startns    zBaseProcess.startcCs||jdSr)r;r terminaterr r r r@szBaseProcess.terminatecCs||jdSr)r;rkillrr r r rAszBaseProcess.killcCs*||j|}|dk r&t|dSr)r;rwaitr r)rtimeoutresr r r r0s zBaseProcess.joincCsJ||tkrdS|jdkr"dS|j}|dkr8dSt|dSdS)NTF)r;rrrr r)r returncoder r r is_alives   zBaseProcess.is_alivecCsH|jdk r>|jdkr td|jd|_|`t|d|_dS)Nz^Cannot close a process while it is still running. You should first call join() or terminate().T)rrr:closer>r rr(rr r r rGs   zBaseProcess.closecCs|jSrr1rr r r r&szBaseProcess.namecCs ||_dSrrH)rr&r r r r&scCs|jddS)NrF)r!getrr r r rszBaseProcess.daemoncCs||jd<dS)Nrr!)rZdaemonicr r r rscCs |jdSNauthkeyrJrr r r rLszBaseProcess.authkeycCst||jd<dSrK)AuthenticationStringr!)rrLr r r rLscCs"||jdkr|jS|jSr)r;rrrr r r exitcodes zBaseProcess.exitcodecCs*||tkrtS|jo$|jjSdSr)r;rr#r$rpidrr r r identszBaseProcess.identcCs4|z|jWStk r.tddYnXdS)Nzprocess not started)r;r>AttributeErrorr:rr r r r=s zBaseProcess.sentinelcCsd}|tkrd}nL|jrd}n@|jtkr2d}n,|jdkrBd}n|j}|dk rZd}nd}t|jd|j g}|jdk r| d|jj | d|j| ||dk rt ||}| d ||jr| d d d |S) NZstartedclosedunknowninitialZstoppedzname=%rzpid=%sz parent=%sz exitcode=%srz<%s> )rr(r%r#r$rrr.r/r1appendrO_exitcode_to_namerIrr0)rrNZstatusinfor r r __repr__s0      zBaseProcess.__repr__c Csvddlm}m}z>z|jdk r,||jt da t a |t}|at|j|j|atjrntz|j|W5~X|dz|d}W5|XWntk r}zJ|jsd}n:t|jdtr|jd}nt j!"t#|jddd}W5d}~XYn2d}ddl$}t j!"d|j%|&YnXW5t|d||X|S)N)utilcontextz process exiting with exitcode %dz child process calling self.run()r z Process %s: )'r[r\ threadingZ _shutdownrXZ_flush_std_streamsZ _start_methodZ_force_start_method itertoolsr8rsetr Z _close_stdinr_ParentProcessr'r%rZ_HAVE_THREAD_NATIVE_IDZ main_threadZ_set_native_idZ_finalizer_registryclearZ_run_after_forkersZ_exit_functionr< SystemExitr6 isinstanceintsysstderrwriter tracebackr& print_exc)rZparent_sentinelr[r\rNZ old_processerjr r r _bootstrap"sR         zBaseProcess._bootstrap)N)N)r/ __module__ __qualname__rr9r;r<r?r@rAr0rFrGpropertyr&setterrrLrNrPrOr=rYrmr r r r rGsB            c@seZdZddZdS)rMcCs,ddlm}|dkrtdtt|ffS)NrZ)get_spawning_popenzJPickling an AuthenticationString object is disallowed for security reasons)r\rr TypeErrorrMbytes)rrrr r r __reduce__Xs   zAuthenticationString.__reduce__N)r/rnrorur r r r rMWsrMc@s6eZdZddZddZeddZd dd ZeZdS) rbcCs4d|_||_||_d|_d|_d|_||_i|_dS)Nr F)r r1_pidr%rr(r>r!)rr&rOr=r r r r9hsz_ParentProcess.__init__cCsddlm}||jgdd SNr)rB)rCZmultiprocessing.connectionrBr>)rrBr r r rFrs z_ParentProcess.is_alivecCs|jSr)rvrr r r rPvsz_ParentProcess.identNcCs ddlm}||jg|ddSrwrx)rrCrBr r r r0zs z_ParentProcess.join)N) r/rnror9rFrprPr0rOr r r r rbfs    rbc@seZdZddZddZdS) _MainProcesscCs8d|_d|_d|_d|_d|_ttddd|_dS)Nr Z MainProcessF z/mp)rLZ semprefix) r r1r%rr(rMr#urandomr!rr r r r9s z_MainProcess.__init__cCsdSrr rr r r rGsz_MainProcess.closeN)r/rnror9rGr r r r rysryrZZSIG_r)$__all__r#rgsignalr`r_Z _weakrefsetrpathabspathgetcwdZ ORIGINAL_DIROSErrorrrrr objectrrtrMrbryrrr8rrar rWr __dict__itemsr&Zsignumr2r r r r  s@    !