Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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()
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())
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)
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)
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)
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
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)
def start(self):
multiprocessing.Process(target=process, args=(self.event_queue,)).start()
eventlet.wsgi.server(eventlet.listen(config.bot.get('listen')), self.handler)