%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/tcpserver.pyc

�
��L]c@�sdZddlmZmZmZmZddlZddlZddlZddl	m
Z
ddlmZddl
mZmZddlmZmZmZddlmZdd	lmZyddlZWnek
r�dZnXd
efd��YZdS(s+A non-blocking, single-threaded TCP server.i(tabsolute_importtdivisiontprint_functiontwith_statementN(tapp_log(tIOLoop(tIOStreamtSSLIOStream(tbind_socketstadd_accept_handlertssl_wrap_socket(tprocess(terrno_from_exceptiont	TCPServercB�s}eZdZd
d
d
d
d�Zdd�Zd�Zd�Zd
ej	dd�Z
dd	�Zd
�Zd�Z
d�ZRS(s�A non-blocking, single-threaded TCP server.

    To use `TCPServer`, define a subclass which overrides the `handle_stream`
    method.

    To make this server serve SSL traffic, send the ``ssl_options`` keyword
    argument with an `ssl.SSLContext` object. For compatibility with older
    versions of Python ``ssl_options`` may also be a dictionary of keyword
    arguments for the `ssl.wrap_socket` method.::

       ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
       ssl_ctx.load_cert_chain(os.path.join(data_dir, "mydomain.crt"),
                               os.path.join(data_dir, "mydomain.key"))
       TCPServer(ssl_options=ssl_ctx)

    `TCPServer` initialization follows one of three patterns:

    1. `listen`: simple single-process::

            server = TCPServer()
            server.listen(8888)
            IOLoop.current().start()

    2. `bind`/`start`: simple multi-process::

            server = TCPServer()
            server.bind(8888)
            server.start(0)  # Forks multiple sub-processes
            IOLoop.current().start()

       When using this interface, an `.IOLoop` must *not* be passed
       to the `TCPServer` constructor.  `start` will always start
       the server on the default singleton `.IOLoop`.

    3. `add_sockets`: advanced multi-process::

            sockets = bind_sockets(8888)
            tornado.process.fork_processes(0)
            server = TCPServer()
            server.add_sockets(sockets)
            IOLoop.current().start()

       The `add_sockets` interface is more complicated, but it can be
       used with `tornado.process.fork_processes` to give you more
       flexibility in when the fork happens.  `add_sockets` can
       also be used in single-process servers if you want to create
       your listening sockets in some way other than
       `~tornado.netutil.bind_sockets`.

    .. versionadded:: 3.1
       The ``max_buffer_size`` argument.
    cC�s�||_||_i|_g|_t|_||_||_|jdk	r�t	|jt
�r�d|jkr~td��ntj
j|jd�s�td|jd��nd|jkr�tj
j|jd�r�td|jd��q�ndS(Ntcertfiles%missing key "certfile" in ssl_optionsscertfile "%s" does not existtkeyfileskeyfile "%s" does not exist(tio_looptssl_optionst_socketst_pending_socketstFalset_startedtmax_buffer_sizetread_chunk_sizetNonet
isinstancetdicttKeyErrortostpathtexistst
ValueError(tselfRRRR((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyt__init__Zs"							!tcC�s#t|d|�}|j|�dS(s/Starts accepting connections on the given port.

        This method may be called more than once to listen on multiple ports.
        `listen` takes effect immediately; it is not necessary to call
        `TCPServer.start` afterwards.  It is, however, necessary to start
        the `.IOLoop`.
        taddressN(Rtadd_sockets(R tportR#tsockets((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pytlistenuscC�sb|jdkr!tj�|_nx:|D]2}||j|j�<t||jd|j�q(WdS(s�Makes this server start accepting connections on the given sockets.

        The ``sockets`` parameter is a list of socket objects such as
        those returned by `~tornado.netutil.bind_sockets`.
        `add_sockets` is typically used in combination with that
        method and `tornado.process.fork_processes` to provide greater
        control over the initialization of a multi-process server.
        RN(RRRtcurrentRtfilenoR	t_handle_connection(R R&tsock((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyR$�s	
cC�s|j|g�dS(sASingular version of `add_sockets`.  Takes a single socket object.N(R$(R tsocket((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyt
add_socket�si�cC�sKt|d|d|d|�}|jr7|j|�n|jj|�dS(s�Binds this server to the given port on the given address.

        To start the server, call `start`. If you want to run this server
        in a single process, you can call `listen` as a shortcut to the
        sequence of `bind` and `start` calls.

        Address may be either an IP address or hostname.  If it's a hostname,
        the server will listen on all IP addresses associated with the
        name.  Address may be an empty string or None to listen on all
        available interfaces.  Family may be set to either `socket.AF_INET`
        or `socket.AF_INET6` to restrict to IPv4 or IPv6 addresses, otherwise
        both will be used if available.

        The ``backlog`` argument has the same meaning as for
        `socket.listen <socket.socket.listen>`.

        This method may be called multiple times prior to `start` to listen
        on multiple ports or interfaces.
        R#tfamilytbacklogN(RRR$Rtextend(R R%R#R.R/R&((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pytbind�s
		icC�sX|jst�t|_|dkr5tj|�n|j}g|_|j|�dS(sXStarts this server in the `.IOLoop`.

        By default, we run the server in this process and do not fork any
        additional child process.

        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 > 1, 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 ``TCPServer.start(n)``.
        iN(RtAssertionErrortTrueRtfork_processesRR$(R t
num_processesR&((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pytstart�s			cC�s>x7|jj�D]&\}}|jj|�|j�qWdS(s�Stops listening for new connections.

        Requests currently in progress may still continue after the
        server is stopped.
        N(RtitemsRtremove_handlertclose(R tfdR+((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pytstop�scC�s
t��dS(sdOverride to handle a new `.IOStream` from an incoming connection.

        This method may be a coroutine; if so any exceptions it raises
        asynchronously will be logged. Accepting of incoming connections
        will not be blocked by this coroutine.

        If this `TCPServer` is configured for SSL, ``handle_stream``
        may be called before the SSL handshake has completed. Use
        `.SSLIOStream.wait_for_handshake` if you need to verify the client's
        certificate or use NPN/ALPN.

        .. versionchanged:: 4.2
           Added the option for this method to be a coroutine.
        N(tNotImplementedError(R tstreamR#((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyt
handle_stream�scC�s�|jdk	r�ts!td��y"t||jdtdt�}Wq�tjk
r~}|jdtj	krx|j
�S�q�tjk
r�}t
|�tjtjfkr�|j
�S�q�Xny�|jdk	r�t|d|jd|jd|j�}n't|d|jd|jd|j�}|j||�}|dk	r\|jj|d��nWn$tk
r�tjd	d
t�nXdS(Ns(Python 2.6+ and OpenSSL required for SSLtserver_sidetdo_handshake_on_connectiRRRcS�s
|j�S(N(tresult(tf((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyt<lambda>ssError in connection callbacktexc_info(RRtsslR2R
R3RtSSLErrortargst
SSL_ERROR_EOFR9R,terrorRterrnotECONNABORTEDtEINVALRRRRRR>t
add_futuret	ExceptionR(R t
connectionR#terrR=tfuture((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyR*�s8	



		
N(t__name__t
__module__t__doc__RR!R'R$R-R,t	AF_UNSPECR1R6R;R>R*(((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyR
%s4				
	(RTt
__future__RRRRRJRR,ttornado.logRttornado.ioloopRttornado.iostreamRRttornado.netutilRR	R
ttornadoRttornado.utilRREtImportErrorRtobjectR
(((s7/usr/lib64/python2.7/site-packages/tornado/tcpserver.pyt<module>s"



Zerion Mini Shell 1.0