How to use the eventlet.wsgi function in eventlet

To help you get started, we’ve selected a few eventlet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / neutron / neutron / wsgi.py View on Github external
def _run(self, application, socket):
        """Start a WSGI server in a new green thread."""
        eventlet.wsgi.server(socket, application,
                             max_size=self.num_threads,
                             log=LOG,
                             keepalive=CONF.wsgi_keep_alive,
                             log_format=CONF.wsgi_log_format,
                             socket_timeout=self.client_socket_timeout)
github gameclosure / hookbox / hookbox / server.py View on Github external
def run(self):
        if not self._bound_socket:
            self._bound_socket = eventlet.listen((self.config.interface, self.config.port))
        eventlet.spawn(eventlet.wsgi.server, self._bound_socket, self._root_wsgi_app, log=EmptyLogShim())
        
        # We can't get the main interface host, port from config, in case it
        # was passed in directly to the constructor as a bound sock.
        main_host, main_port = self._bound_socket.getsockname()
        logger.info("Listening to hookbox on http://%s:%s", main_host, main_port)

        # Possibly create bound_api_socket
        if not self._bound_api_socket:
            api_host, api_port = self.config.web_api_interface, self.config.web_api_port
            if api_host is None: api_host = main_host
            if api_port is None: api_port = main_port
            if (main_host, main_port) != (api_host,  api_port):
                self._bound_api_socket = eventlet.listen((api_host, api_port))
                
        # If we have a _bound_api_socket at this point, (either from constructor, 
        # or previous block) we should turn it into a wsgi server.
github realXtend / tundra / src / Application / PythonScriptModule / pyplugins / websocketserver / async_eventlet_wsgiserver.py View on Github external
def server(sock, site,
           log=None,
           environ=None,
           max_size=None,
           max_http_version=wsgiserver.DEFAULT_MAX_HTTP_VERSION,
           protocol=wsgiserver.HttpProtocol,
           server_event=None,
           minimum_chunk_size=None,
           log_x_forwarded_for=True,
           custom_pool=None,
           keepalive=True,
           log_format=wsgiserver.DEFAULT_LOG_FORMAT):

    sock.settimeout(0.001)
    #sock.settimeout(None)
    
    serv = wsgiserver.Server(sock, sock.getsockname(),
                  site, log,
                  environ=environ,
                  max_http_version=max_http_version,
                  protocol=protocol,
github openstack / swift / swift / common / wsgi.py View on Github external
# let eventlet.wsgi.server log to stderr
        wsgi_logger = None
    # utils.LogAdapter stashes name in server; fallback on unadapted loggers
    if not global_conf:
        if hasattr(logger, 'server'):
            log_name = logger.server
        else:
            log_name = logger.name
        global_conf = {'log_name': log_name}
    app = loadapp(conf['__file__'], global_conf=global_conf)
    max_clients = int(conf.get('max_clients', '1024'))
    pool = RestrictedGreenPool(size=max_clients)
    try:
        # Disable capitalizing headers in Eventlet if possible.  This is
        # necessary for the AWS SDK to work with swift3 middleware.
        argspec = inspect.getargspec(wsgi.server)
        if 'capitalize_response_headers' in argspec.args:
            wsgi.server(sock, app, wsgi_logger, custom_pool=pool,
                        capitalize_response_headers=False)
        else:
            wsgi.server(sock, app, wsgi_logger, custom_pool=pool)
    except socket.error as err:
        if err[0] != errno.EINVAL:
            raise
    pool.waitall()
github openstack / trove / trove / common / base_wsgi.py View on Github external
def run_server(application, port, **kwargs):
    """Run a WSGI server with the given application."""
    sock = eventlet.listen(('0.0.0.0', port))
    eventlet.wsgi.server(sock, application, **kwargs)
github pypiserver / pypiserver / pypiserver / bottle.py View on Github external
def run(self, handler):
        from eventlet import wsgi, listen
        try:
            wsgi.server(listen((self.host, self.port)), handler,
                        log_output=(not self.quiet))
        except TypeError:
            # Fallback, if we have old version of eventlet
            wsgi.server(listen((self.host, self.port)), handler)
github openstack / heat / heat / common / wsgi.py View on Github external
def run_server(self):
        """Run a WSGI server."""
        eventlet.wsgi.HttpProtocol.default_request_version = "HTTP/1.0"
        eventlet.hubs.use_hub('poll')
        eventlet.patcher.monkey_patch(all=False, socket=True)
        self.pool = eventlet.GreenPool(size=self.threads)
        socket_timeout = cfg.CONF.eventlet_opts.client_socket_timeout or None

        # Close write to ensure only parent has it open
        os.close(self.writepipe)
        # Create greenthread to watch for parent to close pipe
        eventlet.spawn_n(self._pipe_watcher)

        try:
            eventlet.wsgi.server(
                self.sock,
                self.application,
                custom_pool=self.pool,
                url_length_limit=URL_LENGTH_LIMIT,
github gameclosure / orbited2 / daemon / orbited2 / server.py View on Github external
def run(self):
        for (iface, port), app in self._wsgi_apps.items():
            print "Orbited listening on http://%s:%s" % (iface or "0.0.0.0", port)
            eventlet.spawn(eventlet.wsgi.server, eventlet.listen((iface,port)), app, log=EmptyLogShim())
        ev = eventlet.event.Event()        
        eventlet.spawn(self._run, ev)
        return ev
github yongluo2013 / osf-openstack-training / code / nova-api / wsgiref-samples / eventlet-wsgiref.py View on Github external
from eventlet import wsgi  
import eventlet  
  
def hello_world(env, start_response):  
    start_response('200 OK', [('Content-Type', 'text/plain')])  
    return ['Hello, World!\r\n']  
  
wsgi.server(eventlet.listen(('', 8090)), hello_world)  
github openstack / heat / heat / common / wsgi.py View on Github external
def start(self, application, default_port):
        """Run a WSGI server with the given application.

        :param application: The application to run in the WSGI server
        :param default_port: Port to bind to if none is specified in conf
        """

        eventlet.wsgi.MAX_HEADER_LINE = self.conf.max_header_line
        self.application = application
        self.default_port = default_port
        self.configure_socket()
        self.start_wsgi()