def uhttpserver(request): tmp = tempfile.NamedTemporaryFile() server = uhttp.UnixWSGIServer(tmp.name, RequestHandler) util.start_thread(server.serve_forever, kwargs={"poll_interval": 0.1}) request.addfinalizer(server.shutdown) request.addfinalizer(tmp.close) return server
def test_server_bind_error(tmpdir): # Make server_bind fail with EPERM tmpdir.chmod(0o600) try: sock = str(tmpdir.join('sock')) with pytest.raises(OSError): uhttp.UnixWSGIServer(sock, RequestHandler) finally: tmpdir.chmod(0o755)
def __init__(self, config): self._config = config self._server = uhttp.UnixWSGIServer(config.images.socket, uhttp.UnixWSGIRequestHandler) if config.images.socket == "": config.images.socket = self.address app = web.Application(config, [(r"/images/(.*)", Images), (r"/tasks/(.*)", Tasks)]) self._server.set_app(app) log.debug("%s listening on %r", self.name, self.address)
def __init__(self, config): self._config = config self._server = uhttp.UnixWSGIServer(config.tickets.socket, uhttp.UnixWSGIRequestHandler) if config.tickets.socket == "": config.tickets.socket = self.address app = web.Application(config, [(r"/tickets/(.*)", imageio_server.Tickets), (r"/profile/", profile.Handler)]) self._server.set_app(app) log.debug("%s listening on %r", self.name, self.address)