Repository URL to install this package:
Version:
3.4.35 ▾
|
ó EYc @ s> d d l Z d d l m Z d d l m Z d d l m Z d d l m Z d d l m Z e j d d Z e j d d Z d e f d YZ d Z d d Z d Z y d d l m Z e j Z Wnf e k r9y d d l m Z Wn e k rd Z q:Xd d e d d d e e d d Z n Xd S( iÿÿÿÿN( t greenio( t greenpool( t greenthread( t socket( t greenletsc C sB t j | t j } | d k r1 | j | n | j | | S( sf Convenience function for opening client sockets. :param addr: Address of the server to connect to. For TCP sockets, this is a (host, port) tuple. :param family: Socket family, optional. See :mod:`socket` documentation for available families. :param bind: Local address to bind to, optional. :return: The connected green socket object. N( R t SOCK_STREAMt Nonet bindt connect( t addrt familyR t sock( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyR s i2 c C s t j | t j } t j d d k rD | j t j t j d n t t d ro | j t j t j d n | j | | j | | S( sB Convenience function for opening server sockets. This socket can be used in :func:`~eventlet.serve` or a custom ``accept()`` loop. Sets SO_REUSEADDR on the socket to save on annoyance. :param addr: Address to listen on. For TCP sockets, this is a (host, port) tuple. :param family: Socket family, optional. See :mod:`socket` documentation for available families. :param backlog: The maximum number of queued connections. Should be at least 1; the maximum value is system-dependent. :return: The listening green socket object. i t wini t SO_REUSEPORT( R R t syst platformt setsockoptt SOL_SOCKETt SO_REUSEADDRt hasattrR R t listen( R R t backlogR ( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyR s t StopServec B s e Z d Z RS( sE Exception class used for quitting :func:`~eventlet.serve` gracefully.( t __name__t __module__t __doc__( ( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyR 3 s c C sa y z | j Wd | j XWn: t j k r6 n' t k r\ t j | t j n Xd S( N( t waitt closet greenlett GreenletExitt ExceptionR t killR t exc_info( t tt server_gtt conn( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyt _stop_checker8 s iè c C s t j | } t j } xl t r yM | j \ } } | j | | | } | j t | | d \ } } } Wq t k r d SXq Wd S( s Runs a server on the supplied socket. Calls the function *handle* in a separate greenthread for every incoming client connection. *handle* takes two arguments: the client socket object, and the client address:: def myhandle(client_sock, client_addr): print("client connected", client_addr) eventlet.serve(eventlet.listen(('127.0.0.1', 9999)), myhandle) Returning from *handle* closes the client socket. :func:`serve` blocks the calling greenthread; it won't return until the server completes. If you desire an immediate return, spawn a new greenthread for :func:`serve`. Any uncaught exceptions raised in *handle* are raised as exceptions from :func:`serve`, terminating the server, so be sure to be aware of the exceptions your application can raise. The return value of *handle* is ignored. Raise a :class:`~eventlet.StopServe` exception to gracefully terminate the server -- that's the only way to get the server() function to return rather than raise. The value in *concurrency* controls the maximum number of greenthreads that will be open at any time handling requests. When the server hits the concurrency limit, it stops accepting new connections until the existing ones complete. N( NNN( R t GreenPoolR t getcurrentt Truet acceptt spawnt linkR$ R R ( R t handlet concurrencyt poolR" R# R t gt( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyt serveD s c O s t | | | S( sx Convenience function for converting a regular socket into an SSL socket. Has the same interface as :func:`ssl.wrap_socket`, but can also use PyOpenSSL. Though, note that it ignores the `cert_reqs`, `ssl_version`, `ca_certs`, `do_handshake_on_connect`, and `suppress_ragged_eofs` arguments when using PyOpenSSL. The preferred idiom is to call wrap_ssl directly on the creation method, e.g., ``wrap_ssl(connect(addr))`` or ``wrap_ssl(listen(addr), server_side=True)``. This way there is no "naked" socket sitting around to accidentally corrupt the SSL session. :return Green SSL object. ( t wrap_ssl_impl( R t at kw( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyt wrap_sslo s ( t ssl( t SSLc O s t d d S( NsP To use SSL with Eventlet, you must install PyOpenSSL or use Python 2.6 or later.( t ImportError( R1 R2 ( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyR0 s c C s t j t j } | d k r. | j | n | d k rJ | j | n | j t j d t j | | } | r | j n | j | S( Nc W s t S( N( R' ( t x( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyt <lambda> s ( R5 t Contextt SSLv23_METHODR t use_certificate_filet use_privatekey_filet set_verifyt VERIFY_NONEt Connectiont set_accept_statet set_connect_state( R t keyfilet certfilet server_sidet cert_reqst ssl_versiont ca_certst do_handshake_on_connectt suppress_ragged_eofst cipherst contextt connection( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyR0 s ( R t eventletR R R t eventlet.greenR t eventlet.supportR R t AF_INETR R R R R R$ R/ R3 R4 t wrap_socketR0 R6 t eventlet.green.OpenSSLR5 t FalseR' ( ( ( sI /home/tvault/.virtenv/lib/python2.7/site-packages/eventlet/convenience.pyt <module> s. +