%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib64/python2.7/site-packages/tornado/
Upload File :
Create Path :
Current File : //usr/lib64/python2.7/site-packages/tornado/process.pyo

�
��L]c@�s�dZddlmZmZmZmZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZyddlZWnek
rdZnXyeWnek
r;e ZnXe	j!Z!d�Z"d
�Z#d�Z$da%dd�Z&d�Z'de(fd��YZ)dS(s�Utilities for working with multiple processes, including both forking
the server into multiple processes and managing subprocesses.
i(tabsolute_importtdivisiontprint_functiontwith_statementN(thexlify(tFuture(tioloop(tPipeIOStream(tgen_log(tset_close_exec(t
stack_context(terrno_from_exceptioncC�shtdkrdSytj�SWntk
r1nXytjd�SWntk
rVnXtjd�dS(s1Returns the number of processors on this machine.itSC_NPROCESSORS_CONFs1Could not detect number of processors; assuming 1N(	tmultiprocessingtNonet	cpu_counttNotImplementedErrortostsysconft
ValueErrorRterror(((s5/usr/lib64/python2.7/site-packages/tornado/process.pyR7s


cC�s�dtjkrdSddl}y"tttjd��d�}Wn1tk
rttt	j	�d�tj
�A}nX|j|�dS(Ntrandomiii�(tsystmodulesRtlongRRturandomRtintttimetgetpidtseed(RR((s5/usr/lib64/python2.7/site-packages/tornado/process.pyt_reseed_randomGs"
$cC�s0tj�\}}t|�t|�||fS(N(RtpipeR	(trtw((s5/usr/lib64/python2.7/site-packages/tornado/process.pyt
_pipe_cloexecUs

idc
�s�|d
ks|dkr$t�}ntjj�rBtd��ntjd|�i��fd�}x0t|�D]"}||�}|d
k	rt|SqtWd}x4�r�yt	j
�\}}Wn1tk
r�}t|�t
jkr�q�n�nX|�krq�n�j|�}t	j|�rEtjd||t	j|��nMt	j|�dkr|tjd||t	j|��ntjd||�q�|d7}||kr�td	��n||�}	|	d
k	r�|	Sq�Wtjd�d
S(seStarts multiple worker processes.

    If ``num_processes`` is None or <= 0, we detect the number of cores
    available on this machine and fork that number of child
    processes. If ``num_processes`` is given and > 0, we fork that
    specific number of sub-processes.

    Since we use processes and not threads, there is no shared memory
    between any server code.

    Note that multiple processes are not compatible with the autoreload
    module (or the ``autoreload=True`` option to `tornado.web.Application`
    which defaults to True when ``debug=True``).
    When using multiple processes, no IOLoops can be created or
    referenced until after the call to ``fork_processes``.

    In each child process, ``fork_processes`` returns its *task id*, a
    number between 0 and ``num_processes``.  Processes that exit
    abnormally (due to a signal or non-zero exit status) are restarted
    with the same id (up to ``max_restarts`` times).  In the parent
    process, ``fork_processes`` returns None if all child processes
    have exited normally, but will otherwise only exit by throwing an
    exception.
    is�Cannot run in multiple processes: IOLoop instance has already been initialized. You cannot call IOLoop.instance() before calling start_processes()sStarting %d processesc�s;tj�}|dkr)t�|a|S|�|<dSdS(Ni(RtforkRt_task_idR(titpid(tchildren(s5/usr/lib64/python2.7/site-packages/tornado/process.pytstart_child�s
s1child %d (pid %d) killed by signal %d, restartings3child %d (pid %d) exited with status %d, restartings!child %d (pid %d) exited normallyis"Too many child restarts, giving upN(RRRtIOLooptinitializedtRuntimeErrorRtinfotrangeRtwaittOSErrorRterrnotEINTRtpoptWIFSIGNALEDtwarningtWTERMSIGtWEXITSTATUSRtexit(
t
num_processestmax_restartsR(R%tidtnum_restartsR&tstatustetnew_id((R's5/usr/lib64/python2.7/site-packages/tornado/process.pytfork_processes_sJ			
cC�stS(spReturns the current task id, if any.

    Returns None if this process was not created by `fork_processes`.
    (R$(((s5/usr/lib64/python2.7/site-packages/tornado/process.pyttask_id�st
SubprocesscB�s�eZdZe�ZeZiZd�Zd�Z	e
d�Zed	d��Zed��Zed��Zed��Zd�ZRS(
s�Wraps ``subprocess.Popen`` with IOStream support.

    The constructor is the same as ``subprocess.Popen`` with the following
    additions:

    * ``stdin``, ``stdout``, and ``stderr`` may have the value
      ``tornado.process.Subprocess.STREAM``, which will make the corresponding
      attribute of the resulting Subprocess a `.PipeIOStream`.
    * A new keyword argument ``io_loop`` may be used to pass in an IOLoop.

    .. versionchanged:: 4.1
       The ``io_loop`` argument is deprecated.
    c
O�s7|jdd�ptjj�|_g}g}|jd�tjkr�t	�\}}||d<|j
||f�|j|�t|d|j�|_
n|jd�tjkrt	�\}}||d<|j
||f�|j|�t|d|j�|_n|jd�tjkrtt	�\}	}
|
|d<|j
|	|
f�|j|
�t|	d|j�|_nytj||�|_Wn(x|D]}tj|�q�W�nXx|D]}tj|�q�WxHddddgD]4}t||�s�t||t|j|��q�q�Wd|_d|_dS(Ntio_looptstdintstdouttstderrR&(R2RRR)tcurrentRBtgetRAtSTREAMR"textendtappendRRCRDREt
subprocesstPopentprocRtclosethasattrtsetattrtgetattrt_exit_callbackt
returncode(
tselftargstkwargstpipe_fdstto_closetin_rtin_wtout_rtout_wterr_rterr_wtfdtattr((s5/usr/lib64/python2.7/site-packages/tornado/process.pyt__init__�sD$







#	cC�sFtj|�|_tj|j�|tj|j<tj|j�dS(s�Runs ``callback`` when this process exits.

        The callback takes one argument, the return code of the process.

        This method uses a ``SIGCHLD`` handler, which is a global setting
        and may conflict if you have other libraries trying to handle the
        same signal.  If you are using more than one ``IOLoop`` it may
        be necessary to call `Subprocess.initialize` first to designate
        one ``IOLoop`` to run the signal handlers.

        In many cases a close callback on the stdout or stderr streams
        can be used as an alternative to an exit callback if the
        signal handler is causing a problem.
        N(	R
twrapRRRAt
initializeRBt_waitingR&t_try_cleanup_process(RTtcallback((s5/usr/lib64/python2.7/site-packages/tornado/process.pytset_exit_callback�sc�s,t����fd�}|j|��S(sReturns a `.Future` which resolves when the process exits.

        Usage::

            ret = yield proc.wait_for_exit()

        This is a coroutine-friendly alternative to `set_exit_callback`
        (and a replacement for the blocking `subprocess.Popen.wait`).

        By default, raises `subprocess.CalledProcessError` if the process
        has a non-zero exit status. Use ``wait_for_exit(raise_error=False)``
        to suppress this behavior and return the exit status without raising.

        .. versionadded:: 4.2
        c�s<|dkr+�r+�jt|d��n
�j|�dS(Ni(t
set_exceptiontCalledProcessErrorRt
set_result(tret(tfuturetraise_error(s5/usr/lib64/python2.7/site-packages/tornado/process.pyRfs(RRg(RTRmRf((RlRms5/usr/lib64/python2.7/site-packages/tornado/process.pyt
wait_for_exit	s	
c�s\�jr
dS�dkr+tjj��ntjtj��fd���_t�_dS(s�Initializes the ``SIGCHLD`` handler.

        The signal handler is run on an `.IOLoop` to avoid locking issues.
        Note that the `.IOLoop` used for signal handling need not be the
        same one used by individual Subprocess objects (as long as the
        ``IOLoops`` are each running in separate threads).

        .. versionchanged:: 4.1
           The ``io_loop`` argument is deprecated.
        Nc�s�j�j�S(N(tadd_callback_from_signalt_cleanup(tsigtframe(tclsRB(s5/usr/lib64/python2.7/site-packages/tornado/process.pyt<lambda>6s(	t_initializedRRR)RFtsignaltSIGCHLDt_old_sigchldtTrue(RsRB((RsRBs5/usr/lib64/python2.7/site-packages/tornado/process.pyRc$s	cC�s0|js
dStjtj|j�t|_dS(s Removes the ``SIGCHLD`` handler.N(RuRvRwRxtFalse(Rs((s5/usr/lib64/python2.7/site-packages/tornado/process.pytuninitialize9s	cC�s1x*t|jj��D]}|j|�qWdS(N(tlistRdtkeysRe(RsR&((s5/usr/lib64/python2.7/site-packages/tornado/process.pyRpAscC�s�ytj|tj�\}}Wn,tk
rM}t|�tjkrNdSnX|dkr^dS|jj|�}|j	j
|j|�dS(Ni(RtwaitpidtWNOHANGR/RR0tECHILDRdR2RBRot_set_returncode(RsR&tret_pidR<R=tsubproc((s5/usr/lib64/python2.7/site-packages/tornado/process.pyReFs	cC�sftj|�r%tj|�|_ntj|�|_|jrb|j}d|_||j�ndS(N(RR3R5RSR6RRR(RTR<Rf((s5/usr/lib64/python2.7/site-packages/tornado/process.pyR�Ts			N(t__name__t
__module__t__doc__tobjectRHRzRuRdRaRgRyRntclassmethodRRcR{RpReR�(((s5/usr/lib64/python2.7/site-packages/tornado/process.pyRA�s
		&	(*R�t
__future__RRRRR0RRvRKRRtbinasciiRttornado.concurrentRttornadoRttornado.iostreamRttornado.logRttornado.platform.autoR	R
ttornado.utilRR
tImportErrorRRt	NameErrorRRiRRR"R$R?R@R�RA(((s5/usr/lib64/python2.7/site-packages/tornado/process.pyt<module>s>"



				T		

Zerion Mini Shell 1.0