Vcn/csDddlZddlZddlZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl m Z ddl mZddl mZddl mZgd Zd Zejd ZGd d eZddZdZdZdZeZejZejZejZejZdS)N) connection)process) reduction)resource_tracker)spawn)util)ensure_runningget_inherited_fdsconnect_to_new_processset_forkserver_preloadiZqcs8eZdZdZdZdZdZdZdZdZ dS) ForkServercs~d|_d|_d|_d|_t j|_dg|_dS)N__main__)_forkserver_address_forkserver_alive_fd_forkserver_pid_inherited_fds threadingZLock_lock_preload_modulesself 3/usr/lib64/python3.11/multiprocessing/forkserver.py__init__zForkServer.__init__"sA#' $(!#"^%% !+ csn|j5|ddddS#1swxYwYdSN)r_stop_unlockedrrr_stopzForkServer._stop*s Z " "    ! ! ! " " " " " " " " " " " " " " " " " "s *..cs |jdStj|jd|_tj|jdd|_t j|jstj|jd|_dS)Nr) roscloserwaitpidris_abstract_socket_namespacerZunlinkrrrrzForkServer._stop_unlocked/s    F *+++$(! 4'+++#01IJJ 0 Id. / / /#'   rcsntd|jDstd||_dS)z>Set list of module names to try to load in forkserver process.c3sBK|]}t|tuVdSr)ZtypeZstr).0Zmod rz z4ForkServer.set_forkserver_preload..@s-EE499#EEEEEErz&module_names must be a list of stringsN)ZallrZ TypeError)rZ modules_namesr#rr z!ForkServer.set_forkserver_preload>sBEEt/DEEEEE FDEE E -rcs|jS)zReturn list of fds inherited from parent process. This returns None if the current process was not started by fork server. )rrrrr zForkServer.get_inherited_fdsDs ""rcs|t|dztkrtdt jtj5}||jtj \}}tj \}}|||j tj g}||z } tj||||ftj|tj|cdddS#tj|tj|xYw#tj|tj|wxYw#1swxYwYdS)a;Request forkserver to create a child process. Returns a pair of fds (status_r, data_w). The calling process can read the child process's pid and (eventually) its returncode from status_r. The calling process should write to data_w the pickled preparation and process data. iz too many fdsN)rlenMAXFDS_TO_SENDZ ValueErrorsocketAF_UNIXZconnectrrpiperrZgetfdrZsendfdsr)rfdsZclientZparent_rchild_wchild_rZparent_wZallfdss rr z!ForkServer.connect_to_new_processLs  s88a<> ) -^,, , ]6> * * "f NN43 4 4 4 " Hg " GXw(A&,..0F cMF "!&&111) !!!!!!! " " " " " " " " """"""!!!!!!!! " " " " " " " " " "s7A(E.D(E.+D>>E*E++E..E25E2cs |j5tj|jet j|jtj\}}|s ddddSt j|jd|_ d|_d|_d}|j r9ddh tj d} fd| D}ni}tjtj5}t!jd}||t'j|st j|d|t j\}} ||g} ||||j |fz}tj} | gt'jz} | d |gz } t'j| | | }n#t j|xYw t j|n#t j|wxYw||_ ||_||_dddn #1swxYwYddddS#1swxYwYdS) zMake sure that a fork server is running. This can be called from any process. Note that usually a child process will just reuse the forkserver started by its parent, so ensure_running() will do nothing. NzCfrom multiprocessing.forkserver import main; main(%d, %d, %r, **%r) main_pathsys_pathZignorecs$i|] \}}|v || Sr.)r"ZxZy desired_keyss r z-ForkServer.ensure_running..s)KKKAl9JK1KKKrr'iz-c)rrrrrr WNOHANGrrrrrZget_preparation_dataitemsr&r'rZarbitrary_addressZbindrr!ZchmodZlistenr(filenoZget_executableZ_args_from_interpreter_flagsZspawnv_passfds) rpidZstatusZcmddatalistenerZaddressalive_rZalive_wZ fds_to_passZexeZargsr/s @rrzForkServer.ensure_runningisZ1 +1 +  + - - -# , j)=rzJJ V1 +1 +1 +1 +1 +1 +1 +1 +2333+/(,0)'+$,C$  +Z8 1(;;KKKKKKKv~.. +($6yAA g&&&8AA-HWe,,,!!!$&799  &#+??#4#4g">KHOO--w8M ""C.00C54#D#F#FFDT3K'D-c4EECCHW%%% HW%%%%BHW%%%%+2(,3)'*$3 + + + + + + + + + + + + + + +11 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +1 +siAI)BI)+A=I)A=G'&H'G>>HIH--I I)I I)I I))I-0I-N) Z__name__Z __module__Z __qualname__rrrr r r rr.rrr r s}---""" ( ( (... ###""":8+8+8+8+8+rr c s |rd|vr[|Ydtj_ tj|tj`n#tj`wxYw|D]"} t |#t $rYwxYwtjtj \}}tj |dtj |dd}tj |tjtji} d| D} tj|i} t%jt$j|5} t)j5} | t._| | t(j| |t(j| |t(j d| D}|rn"||vr*tj|d d ks Jd t:||vrtj|d  tjd tj\}}n#t@$rYnwxYw|dkrn{| !|d}|Ktj"|} tG||n#tH$rYnwxYwtj%|ntMj'd|z| |vr| (d5}tSj*|tVd z}tY|tVkr/t[d.tY||^}}}|%tj/}|dkrd } | %| %||||g}|0| 1te|||| }nM#tf$r@tij5tij6thj78YnwxYwtj9|nm#tj9|wxYw tG||n#tH$rYnwxYw|| |<tj%||D]}tj%|dddn #1swxYwYn-#tt$r }|j;tvj<krYd}~nd}~wwxYwY#1swxYwYddddS#1swxYwYdS)zRun forkserver.r NTFcsdSrr.)Z_unusedrrsigchld_handlerzmain..sigchld_handlers rcs@i|]\}}|tj||Sr.)signal)r"sigval rr0zmain..s:888"csC00888r)r3cs"g|] \}}|j Sr.)Zfileobj)r"ZkeyZeventsr<rz zmain..sOOOMS&CKOOOrrrz Not at EOF?irz.forkserver: waitpid returned unexpected pid %dzToo many ({0:n}) fds to send)=rZcurrent_processZ _inheritingrZimport_main_pathZ __import__Z ImportErrorrZ _close_stdinrr(Z set_blockingr9ZSIGCHLDZSIGINTZSIG_IGNr2 set_wakeup_fdr&r' selectorsZDefaultSelectorZ getsockname _forkserverrZregisterZ EVENT_READZselectreadZ SystemExitr r1ZChildProcessErrorZpopZwaitstatus_to_exitcode write_signedZBrokenPipeErrorrwarningsZwarnZacceptrZrecvfdsr%r$ RuntimeErrorZformatZforkZextendZvalues _serve_oneZ ExceptionsysZ excepthookZexc_infoZstderrZflushZ_exitZOSErrorerrnoZ ECONNABORTED)Z listener_fdr7Zpreloadr,r-ZmodnameZsig_rZsig_wr8handlersZ old_handlersZ pid_to_fdr6ZselectorZrfdsr4Zstsr*Z returncodesr)r+code unused_fdsfdZes rmainrMs    :Y :48G # % % 1 :&y111+--99G+--99999  G 7####     799LE5OE5!!!OE5!!!    v~  H 88&.nn&6&6888L I v~k : : :Yh  " $ $Y(0*2*>*>*@*@ '(I$8999'9#7888%!5666Q P OOX__=N=NOOOD d?%77A..#5DD}DDD$$D=EGE5)))E"')z"bj'A'AHC0"""!E"!8"!"+--T":":" E)+)B3)G)GJ% ,Wj A A A A#2%%% $%HW----%M+>@C+DEEE+E0t#&-!**1-$-'/>A3EFFs88n4/". > E E$'HH!.!.#/#//25.3  gii!8-#$D / ( 0 0 0 ( 0 0 0.5wu-M * 1 1)2B2B2D2D E E E'1'32<2>(@(@$-333 #  ? ? # 0 0 2 2 2 2 23!#% ,Wc : : : :#2%%% $%.5IcNHW---&)-- " I$-$-$-$-$-$-$-$-$-$-$-$-$-$-$-L   7e00 _Q YYYYYYYYYYYYYYYYYYYYYYYYYYsCA A'A77 BBU)BU*A+T"I98T9 JTJ6T=K T KTKAT*BTA'P,+R,AQ6 3R5Q6 6R9TR$ $T(R98T9 S TS 5T; TT TT TU T=T83U8T==UU U U UU!Ucs`tjd|D]\}}tj|||D]}tj||^t _tj_ t _ tj |}tj ||}|S)Nr=)r9r>r2rrr@rrZ_resource_trackerZ_fdrZduprZ_main) r+r)rKrHr:r;rLZparent_sentinelrJs rrErE+s NN$$  S c3  %("[%'+ fWooO ;w 0 0D Krcs d}tj}t||krNtj||t|z }|st d||z }t||kNt|dS)Nrzunexpected EOFr) SIGNED_STRUCTZsizer$rrAZEOFErrorZunpack)rLr5ZlengthrI r read_signedrPBs D  F d))f  GBT* + + -+,, ,   d))f     % %a ((rcst|}|r8tj||}|dkrt d||d}|6dSdS)Nrzshould not get here)rNZpackrZwriterD)rLZnZmsgZnbytesrOrrBrBLst   Q  C "c"" Q; 6455 5&''l r)NN) rGrr?r9r&ZstructrFrrCZrrZcontextrrrrZ__all__r%ZStructrNZobjectr rMrErPrBr@rr r r r.rrrQs   % % % c"" A+A+A+A+A+A+A+A+NAAAAH.)))jll +1$;$;r