VcJ/cs&gdZddlZddlZddlZddlZddlZddlmZ ej ej Z n #e $rdZ YnwxYwdZ dZdZdZGdd eZGd d eZGd d eZGddeZdaeaejdaea[iZeej D] \Z!Z"e!dddkr de!vr de!ee" <![!["eZ#dS)) BaseProcesscurrent_processactive_childrenparent_processN)WeakSetctS)z@ Return process object representing the current process )_current_process0/usr/lib64/python3.11/multiprocessing/process.pyrr%s  r csFtttS)zN Return list of process objects corresponding to live child processes )_cleanuplist _childrenrr r rr+s JJJ  ??r cr)z? Return process object representing the parent process )_parent_processrr r rr3s  r csttD]5}|jt|6dSN)r r _popenpolldiscard)Zp r r r =sH )__!! 8==?? !   a !!r csneZdZdZdZddddifdddZdZdZd Zd Z d Z dd Z d Z dZ edZejdZedZejdZedZejdZedZedZeZedZdZddZedZdS)rz Process objects represent activity that is run in a separate process The class is analogous to `threading.Thread` cstr)ZNotImplementedErrorselfrr _PopenzBaseProcess._PopenMs!!r Nr)daemoncs6tt}tj|fz|_tj|_t j|_tj |_ d|_ d|_ ||_ t||_t!||_|p;t%|jdzdd|jDz|_|||_t.|dS)NF-z:c3s4K|]}t|VdSr)str)Z.0Zi r z z'BaseProcess.__init__..^s(==c!ff======r )Znext_process_counterr _identity_configZcopyosgetpid _parent_pidname _parent_namer_closed_targetZtuple_argsZdict_kwargstype__name__join_namer _danglingadd)rZgroupZtargetr!ZargsZkwargsrcount r __init__zBaseProcess.__init__Ps%&&)3uh>'/4466 9;;,1   4[[ F|| >T$ZZ036XX==dn=====>  ! DK dr cs2|jrtddS)Nzprocess object is closed)r# ValueErrorrrr _check_closedzBaseProcess._check_closedcs% < 9788 8 9 9r csF|jr|j|ji|jdSdS)zQ Method to be run in sub-process; can be overridden in sub-class N)r$r%r&rrr runzBaseProcess.rungs9 < 6 DL$* 5 5 5 5 5 5 6 6r cs|t|||_|jj|_|`|`|`t |dS)z% Start child process N) r1r rrsentinel _sentinelr$r%r&r r,rrr startzBaseProcess.startnsg   kk$'' - L$*dl dr c`||jdS)zT Terminate process; sends SIGTERM signal or uses TerminateProcess() N)r1r terminaterrr r7zBaseProcess.terminates0  r cr6)zT Terminate process; sends SIGKILL signal or uses TerminateProcess() N)r1rkillrrr r8zBaseProcess.kills0  r cs||j|}|t|dSdS)z5 Wait until child process terminates N)r1rwaitr r)rtimeoutZres r r)zBaseProcess.joinsY kw''  $   d # # # # # $ $r cs||turdS|jdS|j}|dSt|dS)z1 Return whether process is alive TNF)r1rrrr r)rZ returncoderr is_alivezBaseProcess.is_alivess  # # 4 ; 5[%%''  4   d # # #5r cs|jd|jtd|jd|_|`t |d|_dS)z Close the Process object. This method releases resources held by the Process object. It is an error to call this method if the child process is still running. Nz^Cannot close a process while it is still running. You should first call join() or terminate().T)rrr0closer4r rr#rrr r=zBaseProcess.closes ; ${!! Q "PQQQ K     DK   d # # # r c|jSrr*rrr r!BaseProcess.names zr cs||_dSrr?)rr!rr r!r@s r cs8|jddS)z4 Return whether process is a daemon rF)rgetrrr rBaseProcess.daemons |%000r cs||jd<dS)z1 Set whether process is a daemon rNr)rZdaemonicrr rrBs "* Xr cs|jdS)NauthkeyrCrrr rDBaseProcess.authkeys|I&&r cs4t||jd<dS)z2 Set authorization key of process rDN)AuthenticationStringr)rrDrr rDrEs #7w"?"? Yr csx||j|jS|jS)zM Return exit code of process or `None` if it has yet to stop )r1rrrrr exitcodezBaseProcess.exitcodes<  ; ; {!!!r cs||turtjS|jo |jjS)zU Return identifier (PID) of process or `None` if it has yet to start )r1rrrrpidrrr identzBaseProcess.identsA  # # 39;; ;24;? 2r csv| |jS#t$rtddwxYw)z{ Return a file descriptor (Unix) or handle (Windows) suitable for waiting for process termination. zprocess not startedN)r1r4ZAttributeErrorr0rrr r3zBaseProcess.sentinelsO  >> ! > > >233 = >s8csd}|turd}nS|jrd}nI|jtjkrd}n*|jd}n |j}|d}nd}t|jd|j zg}|j"| d|jj z| d|jz| ||3t ||}| d |z|jr| d d d |zS) NZstartedZclosedZunknownZinitialZstoppedzname=%rzpid=%sz parent=%sz exitcode=%srz<%s>z )rr#r rrrrr'r(r*ZappendrH_exitcode_to_namerArr))rrGZstatusinfo r __repr__zBaseProcess.__repr__sR # # #FF \ #FF   , #FF [ #FF{''))H #""T #Y%;< ; 4 KK4;?2 3 3 3 K$"22333 F  2(,,Xx@@H KK 0 1 1 1 ; " KK ! ! !&&r csddlm}m} |j||jt jdata | t}|a t|j |j|at jr%t!j |~n#~wxYw|d |d}|n#|wxYwn#t0$rl}|jd}nXt5|jt6r|j}n6t8jt?|jdzd}Yd}~nKd}~wd}ddl }t8jd|j!z|"YnxYwt!j#|d|z|$nD#t!j#|d|z|$wxYw|S)N)utilcontextz child process calling self.run()rz z Process %s: z process exiting with exitcode %d)%rOrPZ _start_methodZ_force_start_method itertoolsr-rsetr Z _close_stdinr_ParentProcessr"r r threadingZ_HAVE_THREAD_NATIVE_IDZ main_threadZ_set_native_id _after_forkrKr2Z_exit_functionZ SystemExitZcodeZ isinstanceZintsysZstderrZwriter tracebackr!Z print_excZ _shutdownZ_flush_std_streams)rZparent_sentinelrOrPZ old_processrGZerXr.r _bootstrapzBaseProcess._bootstrap"s########( &! @++D,>???(q11 I      *K# ,!4#3_FFO/ 9%''66888   """ KK II8 9 9 9 & ##%%%%##%%%%%   v AFC(( 6   QVt!3444 "H     J  _ty8 9 9 9    ! ! ! ! !   ! ! ! II88C D D D  # # % % % %   ! ! ! II88C D D D  # # % % % %scB,D.7C D. CD.)D?D.D**D.-H*. G'8A"FH*AG'%H**AI+cslddlm}|j|dS)NrNrO)rQrOZ_finalizer_registryZclearZ_run_after_forkersrZrr rVzBaseProcess._after_forkRsA  &&((( !!!!!r r)r( __module__ __qualname__Z__doc__rr/r1r2r5r7r8r)r<r=propertyr!ZsetterrrDrGrIrHr3rMrYZ staticmethodrVrr r rrGs """"$T2&999666$    $ $ $ $&"X [[11X1  ]**]*''X' ^@@^@ ""X"33X3 C  > >X >'''>....`""\"""r rcseZdZdZdS)rFcsnddlm}|tdtt |ffS)NrN)get_spawning_popenzJPickling an AuthenticationString object is disallowed for security reasons)rPr^Z TypeErrorrFbytes)rr^rr __reduce__zAuthenticationString.__reduce__^sQ//////     2 $eDkk^33r N)r(r[r\r`rr r rFrF]s#44444r rFcs<eZdZdZdZedZddZeZdS)rTcsvd|_||_||_d|_d|_d|_||_i|_dS)NrF)rr*_pidr rr#r4r)rr!rHr3rLr r/z_ParentProcess.__init__ns?    ! r cs6ddlm}||jgd S)Nrr9r:Zmultiprocessing.connectionr9r4)rr9rr r<z_ParentProcess.is_alivexs13333334(!44444r cr>r)rarrr rIz_ParentProcess.ident|s yr Ncs8ddlm}||jg|dS)z6 Wait until parent process terminates rrbrcNrd)rr:r9r;r r)z_ParentProcess.joins6 433333 dn w//////r r) r(r[r\r/r<r]rIr)rHrr r rTrTlsb555X0000 CCCr rTcseZdZdZdZdS) _MainProcesscsd|_d|_d|_d|_d|_t t jddd|_dS)NrZ MainProcessFi z/mp)rDZ semprefix) rr*r rr#rFrZurandomrrrr r/z_MainProcess.__init__sN"   #7 2#G#G%*,, r csdSrrrrr r=z_MainProcess.closes r N)r(r[r\r/r=rr r reres2,,,$     r rerNiZSIGZ_r)$Z__all__rrWZsignalrRrUZ _weakrefsetrZpathZabspathZgetcwdZ ORIGINAL_DIRZOSErrorrrrr Zobjectrr_rFrTrerrr-rrSr rJr Z__dict__Zitemsr!Zsignumr+rr r rfs@     7??929;;//LLLLL !!!O"O"O"O"O"&O"O"O"l444445444[B     ;   0<>>"9?1%% CEE  D..001100LD& BQBx03d?0%/ZZ6'"& GII s'AAA