How to use the eventlet.wsgi.server 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 gameclosure / orbited2 / tests / servers / eventlet / start.py View on Github external
def main():
    app = URLMap()
    app['/echo'] = handle
    static_path = os.path.join(os.path.split(os.path.abspath(__file__))[0], 'static')
    app['/'] = static.Cling(static_path)

    # run an example app from the command line            
    listener = eventlet.listen(('localhost', 8013))
    print "\nListening http://localhost:8013/ in your websocket-capable browser.\n"
    eventlet.spawn(listen_tcp)
    wsgi.server(listener, app)
github boothead / stargate / stargate / test_utils.py View on Github external
running it.

        Kills any previously-running server.
        """
        if self.killer:
            greenthread.kill(self.killer)
            eventlet.sleep(0)
        app = self.config.make_wsgi_app()
        new_kwargs = dict(max_size=128,
                          log=self.logfile)
        new_kwargs.update(kwargs)

        sock = eventlet.listen(('localhost', 0))

        self.port = sock.getsockname()[1]
        self.killer = eventlet.spawn_n(wsgi.server, sock, app, **new_kwargs)
github openstack / swift / test / unit / obj / test_server.py View on Github external
def test_chunked_content_length_mismatch_zero(self):
        listener = listen(('localhost', 0))
        port = listener.getsockname()[1]
        killer = spawn(wsgi.server, listener, self.object_controller,
                       NullLogger())
        sock = connect_tcp(('localhost', port))
        fd = sock.makefile()
        fd.write('PUT /sda1/p/a/c/o HTTP/1.1\r\nHost: localhost\r\n'
                 'Content-Type: text/plain\r\n'
                 'Connection: close\r\nX-Timestamp: %s\r\n'
                 'Content-Length: 0\r\n'
                 'Transfer-Encoding: chunked\r\n\r\n'
                 '2\r\noh\r\n4\r\n hai\r\n0\r\n\r\n' % normalize_timestamp(
                     1.0))
        fd.flush()
        headers = readuntil2crlfs(fd)
        exp = 'HTTP/1.1 201'
        self.assertEquals(headers[:len(exp)], exp)
        sock = connect_tcp(('localhost', port))
        fd = sock.makefile()
github StackStorm / st2 / st2actioncontroller / st2actioncontroller / cmd / actioncontroller.py View on Github external
def __run_server():

    host = cfg.CONF.action_controller_api.host
    port = cfg.CONF.action_controller_api.port

    LOG.info("action API is serving on http://%s:%s (PID=%s)",
             host, port, os.getpid())

    wsgi.server(eventlet.listen((host, port)), app.setup_app())
github jmcfarlane / notable / notable / 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 alardus / candybox / cava / 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 darkf / darkfo / mpserv.py View on Github external
elif t in ("objSetOpen", "objMove"):
                    self.relay(msg)

                elif t == "close":
                    self.disconnected("close message received")
                    break
        except (EOFError, OSError):
            self.disconnected("socket closed")

@websocket.WebSocketWSGI
def connection(ws):
    con = Connection(ws)
    con.serve()

if __name__ == "__main__":
    wsgi.server(eventlet.listen(('', 8090)), connection)
github StackStorm / st2 / st2stream / st2stream / cmd / api.py View on Github external
sock = eventlet.listen((host, port))

    def queue_shutdown(signal_number, stack_frame):
        eventlet.spawn_n(
            shutdown_server_kill_pending_requests,
            sock=sock,
            worker_pool=worker_pool,
            wait_time=WSGI_SERVER_REQUEST_SHUTDOWN_TIME,
        )

    # We register a custom SIGINT handler which allows us to kill long running active requests.
    # Note: Eventually we will support draining (waiting for short-running requests), but we
    # will still want to kill long running stream requests.
    register_stream_signal_handlers(handler_func=queue_shutdown)

    wsgi.server(sock, app.setup_app(), custom_pool=worker_pool)
    return 0
github Pavion / tvstreamrecord / 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 jamesmeneghello / pynab / pynab / xmpp.py View on Github external
def start(self):
        multiprocessing.Process(target=process, args=(self.event_queue,)).start()
        eventlet.wsgi.server(eventlet.listen(config.bot.get('listen')), self.handler)