Plan 9 from Bell Labs’s /usr/web/sources/contrib/stallion/root/sys/lib/python2.7/multiprocessing/forking.pyo

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�`^c@sddlZddlZddlZddlZddlmZmZddddddgZd	�Zdd
l	m
Z
de
fd��YZd�Zej
eej�e�d
�Zej
eej�e�ej
eej�e�yddlmZWnek
rn#Xd�Zd�Zej
ee�ejdkr�ddlZejZejZej Z de!fd��YZ"n}ddl#Z#ddl$Z$ddl%Z%ddlZddl&m'Z'm(Z(m)Z)ddlm*Z*ddl	m+Z+m,Z,dd�Z.dZ/ejdko%e0ede1�Z2ej3j4�j5d�Z6e'j7Ze'j8Z e6rsej9j:ej;d�a<n	ej3a<d�Z=de1d�Zde!fd��YZ"d�Z>d �Z?d!�Z@d"�ZAd#�ZBd$�ZCej
e(eC�ej
e)eC�gZDd%�ZEdS(&i�N(tutiltprocesstPopentassert_spawningtexitt	duplicatetclosetForkingPicklercCs,tj�s(tdt|�j��ndS(NsF%s objects should only be shared between processes through inheritance(Rtthread_is_spawningtRuntimeErrorttypet__name__(tself((s-/sys/lib/python2.7/multiprocessing/forking.pyR0s(tPicklercBs&eZejj�Zed��ZRS(cs �fd�}||j|<dS(Ncs#�|�}|jd||�dS(Ntobj(tsave_reduce(RRtrv(treduce(s-/sys/lib/python2.7/multiprocessing/forking.pyt
dispatcherAs(tdispatch(tclsR
RR((Rs-/sys/lib/python2.7/multiprocessing/forking.pytregister?s(Rt
__module__R
RtcopytclassmethodR(((s-/sys/lib/python2.7/multiprocessing/forking.pyR<scCsE|jdkr(t|j|jjffSt|j|jjffSdS(N(tim_selftNonetgetattrtim_classtim_funct	func_name(tm((s-/sys/lib/python2.7/multiprocessing/forking.pyt_reduce_methodFscCst|j|jffS(N(Rt__objclass__R(R((s-/sys/lib/python2.7/multiprocessing/forking.pyt_reduce_method_descriptorMs(tpartialcCs"t|j|j|jpiffS(N(t_rebuild_partialtfunctargstkeywords(tp((s-/sys/lib/python2.7/multiprocessing/forking.pyt_reduce_partial\scCst|||�S(N(R#(R%R&R'((s-/sys/lib/python2.7/multiprocessing/forking.pyR$^stwin32cBsDeZd�Zejd�Zdd�Zd�Ze	d��Z
RS(cCs�tjj�tjj�d|_tj�|_|jdkr�dtj	kriddl
}|j�n|j�}tjj�tjj�tj
|�ndS(Nitrandomi�(tsyststdouttflushtstderrRt
returncodetostforktpidtmodulesR+tseedt
_bootstrapt_exit(Rtprocess_objR+tcode((s-/sys/lib/python2.7/multiprocessing/forking.pyt__init__ts

	


cCs�|jdkr�x\trmytj|j|�\}}Wn/tjk
rh}|jtjkrdqndSXPqW||jkr�tj	|�r�tj
|�|_q�tj|�|_q�n|jS(N(R0RtTrueR1twaitpidR3terrorterrnotEINTRtWIFSIGNALEDtWTERMSIGtWEXITSTATUS(RtflagR3tstste((s-/sys/lib/python2.7/multiprocessing/forking.pytpoll�s	cCs�|dkr|jd�Stj�|}d}xb|j�}|dk	rNPn|tj�}|dkrnPnt|d|d�}tj|�q2|S(Nig�Mb@?ig����(RRFttimetmintsleep(Rttimeouttdeadlinetdelaytrest	remaining((s-/sys/lib/python2.7/multiprocessing/forking.pytwait�s
cCsd|jdkr`ytj|jtj�Wq`tk
r\}|jdd�dkr]�q]q`XndS(NRJg����(	R0RR1tkillR3tsignaltSIGTERMtOSErrorRO(RRE((s-/sys/lib/python2.7/multiprocessing/forking.pyt	terminate�scCstS(N(tFalse(((s-/sys/lib/python2.7/multiprocessing/forking.pyR�sN(RRR:R1tWNOHANGRFRRORTtstaticmethodR(((s-/sys/lib/python2.7/multiprocessing/forking.pyRrs
		(R*t
ConnectiontPipeConnectioni(tFinalize(tloadtHIGHEST_PROTOCOLcCst||�j|�dS(N(Rtdump(Rtfiletprotocol((s-/sys/lib/python2.7/multiprocessing/forking.pyR]�sitfrozenspythonservice.exes
python.execCs
|adS(N(t_python_exe(texe((s-/sys/lib/python2.7/multiprocessing/forking.pytset_executable�scCsF|dkrtj�}ntjtj�||d|tj�j�S(Ni(Rt_subprocesstGetCurrentProcesstDuplicateHandletDUPLICATE_SAME_ACCESStDetach(thandlettarget_processtinheritable((s-/sys/lib/python2.7/multiprocessing/forking.pyR�s
cBs_eZdZej�Zd�Zed��Zed��Z	dd�Zd�Zd�Z
RS(sH
        Start a subprocess to run the code of a process object
        c
Cs7tj�\}}ttj|�dt�}tj|�t�|g}djd�|D��}t	j
t|ddddddd�\}}}}	|j
�t|�||_d|_||_t|j�}
tj|d�}t|�tj_z$t|
|t�t||t�Wdtj`|j�XdS(NRkt css|]}d|VqdS(s"%s"N((t.0tx((s-/sys/lib/python2.7/multiprocessing/forking.pys	<genexpr>siitwb(R1tpipeRtmsvcrtt
get_osfhandleR;Rtget_command_linetjoinRdt
CreateProcessRaRtCloseR3R0t_handletget_preparation_datat_nametfdopentintRt_tlstprocess_handleR]R\(RR8trfdtwfdtrhandletcmdthpthtR3ttidt	prep_datatto_child((s-/sys/lib/python2.7/multiprocessing/forking.pyR:�s(
-

				cCsttjdd�dk	S(NR}(RRR|R(((s-/sys/lib/python2.7/multiprocessing/forking.pyRscCst|tjj�S(N(RRR|R}(Ri((s-/sys/lib/python2.7/multiprocessing/forking.pytduplicate_for_childscCs�|jdkr�|dkr'tj}ntdt|dd��}tjt|j�|�}|tjkr�tj	|j�}|t
kr�tj}n||_q�n|jS(Nii�g�
R0RRdtINFINITEtmaxR{tWaitForSingleObjectRwt
WAIT_OBJECT_0tGetExitCodeProcesst	TERMINATERQRR(RRJtmsecsRMR9((s-/sys/lib/python2.7/multiprocessing/forking.pyRO"s
cCs|jdd�S(NRJi(RO(R((s-/sys/lib/python2.7/multiprocessing/forking.pyRF2scCse|jdkraytjt|j�t�Wqatk
r]|jdd�dkr^�q^qaXndS(NRJg����(	R0RRdtTerminateProcessR{RwR�tWindowsErrorRO(R((s-/sys/lib/python2.7/multiprocessing/forking.pyRT5s
N(RRt__doc__tthreadt_localR|R:RWRR�RRORFRT(((s-/sys/lib/python2.7/multiprocessing/forking.pyR�s	!	cCs.t|�dkr&|ddkr&tStSdS(sE
        Return whether commandline indicates we are forking
        iis--multiprocessing-forkN(tlenR;RU(targv((s-/sys/lib/python2.7/multiprocessing/forking.pyt
is_forkingAs"cCs'ttj�r#t�tj�ndS(sM
        Run code for process object if this in not the main process
        N(R�R,R�tmainR(((s-/sys/lib/python2.7/multiprocessing/forking.pytfreeze_supportLscCstttj�dt�r'td��nttdt�rFtjdgSd}tj�}t	g|d|dgSdS(sR
        Returns prefix of command line used for spawning a child process
        t_inheritings�
            Attempt to start a new process before the current process
            has finished its bootstrapping phase.

            This probably means that you are on Windows 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 a Windows executable.R`s--multiprocessing-forks0from multiprocessing.forking import main; main()s-cN(
RRtcurrent_processRUR	R,t
executableRt_args_from_interpreter_flagsRa(tprogtopts((s-/sys/lib/python2.7/multiprocessing/forking.pyRsUs
cCs�ttjd�}tj|tj�}tj|d�}tt	j
�_t|�}t
|�t|�}tt	j
�_|j�|j�}t|�dS(s?
        Run code specified by data received over pipe
        i�trbN(R{R,R�Rqtopen_osfhandleR1tO_RDONLYRzR;RR�R�R[tprepareRURR6R(Ritfdtfrom_parenttpreparation_dataRtexitcode((s-/sys/lib/python2.7/multiprocessing/forking.pyR�ps

c
Cs.ddlm}m}td|dtjdtjd|dtjdtj	�j
�}|dk	rt|j�|d	<nt
r*tr*ttjd
dd�}|r�tjddkr�tjd}n|dk	r*tjj|�rtjdk	rtjjtj|�}ntjj|�|d<q*n|S(sU
        Return info about parent needed by child to unpickle process object
        i(t_loggert_log_to_stderrtnametsys_pathtsys_argvt
log_to_stderrtorig_dirtauthkeyt	log_levelt__main__t__file__its-ct	main_pathN(R�s-c(RR�R�tdictR,tpathR�RtORIGINAL_DIRR�R�RtgetEffectiveLeveltWINEXEt
WINSERVICERR4R1tisabsRttnormpath(R�R�R�tdR�((s-/sys/lib/python2.7/multiprocessing/forking.pyRx�s(			cCsVtj�s(tdt|�j��nt|�tj|j��|j|jffS(NsLBy default %s objects can only be shared between processes
using inheritance(	RRR	R
RR�tfilenotreadabletwritable(tconn((s-/sys/lib/python2.7/multiprocessing/forking.pytreduce_connection�sc
Cs�tjtjd�d|kr6|dtj�_nd|krX|dtj�_nd|kr{|dr{tj	�nd|kr�tj
�j|d�nd|kr�|dt_nd|kr�|dt_
nd|kr�j|d�nd	|kr|d	t_nd
|kr�|d
}tjjtjj|��d}|dkrztjjtjj|��}n|d
kr�ddl}|dkr�d}nTtjj|�jd�r�jjtjj|��g}ntjj|�g}|j||�\}}}z|jd|||�}Wd|rH|j�nX|tjd<d|_xM|jj�D]9}	y|	jdkr�d|	_nWqotk
r�qoXqoWq�ndS(sE
    Try to get current process ready to unpickle process object
    R�R�R�R�R�R�R�tdirR�R�iR:tipythoni�Ns__init__.pyt__parents_main__(told_main_modulestappendR,R4RR�R�t_authkeyRR�t
get_loggertsetLevelR�R�R1tchdirR�tsplitexttbasenametdirnametimpRt
startswithtfind_moduletload_moduleRRt__dict__tvaluesRt	Exception(
tdataR�t	main_nameR�tdirsR^t	path_nametetctmain_moduleR((s-/sys/lib/python2.7/multiprocessing/forking.pyR��sV

"!	$
	
(FR1R,RQR>tmultiprocessingRRt__all__RtpickleR
RR RR
tsaveR"tlistR�R{t__add__t	functoolsR#tImportErrorR)R$tplatformRGR7RtdupRRtobjectRR�RqRdt_multiprocessingR*RXRYRZR[R\RR]R�RRUR�R�tlowertendswithR�tExitProcesstCloseHandleR�Rttexec_prefixRaRcR�R�RsR�RxR�R�R�(((s-/sys/lib/python2.7/multiprocessing/forking.pyt<module>#sn	
		
					G!				
N						"		

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].