Viewing File: /opt/alt/python35/lib64/python3.5/multiprocessing/__pycache__/forkserver.cpython-35.pyc



Yf @sdddlZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
ddlmZd	d
ddgZd
ZejdZGdddeZddddZddZddZddZeZejZejZejZejZdS)N)
connection)process)	reduction)semaphore_tracker)spawn)utilensure_runningget_inherited_fdsconnect_to_new_processset_forkserver_preloadQc@sLeZdZddZddZddZddZd	d
ZdS)
ForkServercCs:d|_d|_d|_tj|_dg|_dS)N__main__)_forkserver_address_forkserver_alive_fd_inherited_fds	threadingZLock_lock_preload_modules)selfr?/opt/alt/python35/lib64/python3.5/multiprocessing/forkserver.py__init__!s
			zForkServer.__init__cCs5tdd|jDs(td||_dS)z>Set list of module names to try to load in forkserver process.css!|]}t|tkVqdS)N)typestr).0modrrr	<genexpr>*sz4ForkServer.set_forkserver_preload.<locals>.<genexpr>z&module_names must be a list of stringsN)allr	TypeError)rZ
modules_namesrrrr(sz!ForkServer.set_forkserver_preloadcCs|jS)zReturn list of fds inherited from parent process.

        This returns None if the current process was not started by fork
        server.
        )r)rrrrr
.szForkServer.get_inherited_fdscCs
|jt|dtkr,tdtjtj}|j|jtj	\}}tj	\}}|||j
tjg}||7}zJyt
j||||fSWn%tj|tj|YnXWdtj|tj|XWdQRXdS)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.
        ztoo many fdsN)r	lenMAXFDS_TO_SEND
ValueErrorsocketAF_UNIXZconnectrospiperrZgetfdrZsendfdsclose)rfdsZclientZparent_rchild_wchild_rZparent_wZallfdsrrrr6s&




z!ForkServer.connect_to_new_processcs|jtj|jdk	r'dSdd}|jr}ddhtjd}tfdd|jD}ni}t	j	t	j

}tjd	}|j
|tj|d
|jtj\}}zyy|j|g}||j||j|f;}tj}|gtj}	|	d|g7}	tj||	|}
Wntj|YnXWdtj|X||_||_WdQRXWdQRXdS)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.
        Nz-from multiprocessing.forkserver import main; zmain(%d, %d, %r, **%r)	main_pathsys_pathignorec3s-|]#\}}|kr||fVqdS)Nr)rxy)desired_keysrrres	z,ForkServer.ensure_running.<locals>.<genexpr>r'iz-c)rrr	rrrZget_preparation_datadictitemsr&r'rZarbitrary_addressZbindr(chmodZlistenr)filenoZget_executablerZ_args_from_interpreter_flagsZspawnv_passfdsr*r)rcmddatalistenerZaddressalive_rZalive_wZfds_to_passZexeargspidr)r3rr	Ss>

	(



	zForkServer.ensure_runningN)__name__
__module____qualname__rrr
rr	rrrrrs
rc4Csx|rd|krN|dk	rNdtj_ztj|Wdtj`Xx1|D])}yt|WqUtk
r}YqUXqUWtjt	j
t	jt	jt	j
i}dd|jD}tjtjd|}tj}	|jt_|	j|tj|	j|tjxAyx$dd|	jD}
|
r+Pq+W||
krtj|d	d
ksytt||
kst|jd}d	}tjdkrzPyt||||Wn2t k
r
t!j"t!j#t!j$j%YnXWdtj&|XWdQRXWq%t'k
ra}
z|
j(t(j)krOWYdd}
~
Xq%Xq%WWdQRXWdQRXdS)zRun forkserver.rNTcSs+i|]!\}}tj|||qSr)signal)rsigvalrrr
<dictcomp>s	zmain.<locals>.<dictcomp>r7cSsg|]\}}|jqSr)Zfileobj)rkeyZeventsrrr
<listcomp>s	zmain.<locals>.<listcomp>rr)*rZcurrent_processZ_inheritingrZimport_main_path
__import__ImportErrorrZ_close_stdinrASIGCHLDSIG_IGNSIGINTSIG_DFLr5r&r'	selectorsZDefaultSelectorZgetsockname_forkserverrregisterZ
EVENT_READZselectr(readAssertionError
SystemExitZacceptfork
_serve_one	Exceptionsys
excepthookexc_infostderrflush_exitOSErrorerrnoZECONNABORTED)Zlistener_fdr;Zpreloadr.r/modnamehandlersZold_handlersr:ZselectorZrfdsscodeerrrmainsV


	
	
rdcCs|jtj|x*|jD]\}}tj||q$Wtj|td}|jt|tks|t|^}}t	_
}	t	_|	tj
_t|tjdtjkrddl}
|
jtj|}t||dS)Nrrandomr)r*r(r5rArZrecvfdsr$r#rRrOrrrZ_semaphore_trackerZ_fdwrite_unsignedgetpidrWmodulesreZseedr_main)rar:r;r`rBrCr+r-r,ZstfdrerbrrrrUs



rUcCsqd}tj}xNt||kr_tj||t|}|sRtd||7}qWtj|dS)NrGzunexpected EOFr)UNSIGNED_STRUCTsizer#r(rQEOFErrorZunpack)fdr9Zlengthrarrr
read_unsigneds	rncCsZtj|}xD|rUtj||}|dkrBtd||d}qWdS)Nrzshould not get here)rjZpackr(writeRuntimeError)rmnmsgnbytesrrrrfs	rf)r^r(rNrAr&ZstructrWrrrrrrr__all__r$ZStructrjobjectrrdrUrnrfrOr	r
rrrrrr<module>s6		h=!
				
Back to Directory File Manager