当前位置: 首页>>代码示例>>Python>>正文


Python wsgi.Server方法代码示例

本文整理汇总了Python中oslo_service.wsgi.Server方法的典型用法代码示例。如果您正苦于以下问题:Python wsgi.Server方法的具体用法?Python wsgi.Server怎么用?Python wsgi.Server使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_service.wsgi的用法示例。


在下文中一共展示了wsgi.Server方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, name, use_ssl=False):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param use_ssl: Wraps the socket in an SSL context if True.
        :returns: None
        """
        self.name = name
        self.app = app.load_app()
        self.workers = (CONF.api.workers or processutils.get_worker_count())
        if self.workers and self.workers < 1:
            raise exception.ConfigInvalid(
                _("api_workers value of %d is invalid, "
                  "must be greater than 0.") % self.workers)

        self.server = wsgi.Server(CONF, name, self.app,
                                  host=CONF.api.host_ip,
                                  port=CONF.api.port,
                                  use_ssl=use_ssl) 
开发者ID:openstack,项目名称:zun,代码行数:21,代码来源:service.py

示例2: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, app, name, listen, max_url_len=None):
        super(WSGIService, self).__init__(name)
        self.app = app
        self.name = name

        self.listen = listen

        self.servers = []

        for address in self.listen:
            host, port = netutils.parse_host_port(address)
            server = wsgi.Server(
                CONF, name, app,
                host=host,
                port=port,
                pool_size=CONF['service:api'].threads,
                use_ssl=sslutils.is_enabled(CONF),
                max_url_len=max_url_len
            )

            self.servers.append(server) 
开发者ID:openstack,项目名称:designate,代码行数:23,代码来源:service.py

示例3: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, name):
        self._host = CONF.api_listen
        self._port = CONF.api_listen_port

        if platform.system() == "Windows":
            self._workers = 1
        else:
            self._workers = (
                CONF.api_workers or processutils.get_worker_count())

        self._loader = wsgi.Loader(CONF)
        self._app = self._loader.load_app(name)

        self._server = wsgi.Server(CONF,
                                   name,
                                   self._app,
                                   host=self._host,
                                   port=self._port) 
开发者ID:cloudbase,项目名称:vdi-broker,代码行数:20,代码来源:service.py

示例4: test_socket_options_for_simple_server

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_socket_options_for_simple_server(self):
        # test normal socket options has set properly
        self.config(tcp_keepidle=500)
        server = wsgi.Server(self.conf, "test_socket_options", None,
                             host="127.0.0.1", port=0)
        server.start()
        sock = server.socket
        self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET,
                                            socket.SO_REUSEADDR))
        self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET,
                                            socket.SO_KEEPALIVE))
        if hasattr(socket, 'TCP_KEEPIDLE'):
            self.assertEqual(self.conf.tcp_keepidle,
                             sock.getsockopt(socket.IPPROTO_TCP,
                                             socket.TCP_KEEPIDLE))
        self.assertFalse(server._server.dead)
        server.stop()
        server.wait()
        self.assertTrue(server._server.dead) 
开发者ID:openstack,项目名称:oslo.service,代码行数:21,代码来源:test_wsgi.py

示例5: test_uri_length_limit

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_uri_length_limit(self):
        eventlet.monkey_patch(os=False, thread=False)
        server = wsgi.Server(self.conf, "test_uri_length_limit", None,
                             host="127.0.0.1", max_url_len=16384, port=33337)
        server.start()
        self.assertFalse(server._server.dead)

        uri = "http://127.0.0.1:%d/%s" % (server.port, 10000 * 'x')
        resp = requests.get(uri, proxies={"http": ""})
        eventlet.sleep(0)
        self.assertNotEqual(requests.codes.REQUEST_URI_TOO_LARGE,
                            resp.status_code)

        uri = "http://127.0.0.1:%d/%s" % (server.port, 20000 * 'x')
        resp = requests.get(uri, proxies={"http": ""})
        eventlet.sleep(0)
        self.assertEqual(requests.codes.REQUEST_URI_TOO_LARGE,
                         resp.status_code)
        server.stop()
        server.wait() 
开发者ID:openstack,项目名称:oslo.service,代码行数:22,代码来源:test_wsgi.py

示例6: test_socket_options_for_ssl_server

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_socket_options_for_ssl_server(self):
        # test normal socket options has set properly
        self.config(tcp_keepidle=500)
        server = wsgi.Server(self.conf, "test_socket_options", None,
                             host="127.0.0.1", port=0, use_ssl=True)
        server.start()
        sock = server.socket
        self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET,
                                            socket.SO_REUSEADDR))
        self.assertEqual(1, sock.getsockopt(socket.SOL_SOCKET,
                                            socket.SO_KEEPALIVE))
        if hasattr(socket, 'TCP_KEEPIDLE'):
            self.assertEqual(CONF.tcp_keepidle,
                             sock.getsockopt(socket.IPPROTO_TCP,
                                             socket.TCP_KEEPIDLE))
        server.stop()
        server.wait() 
开发者ID:openstack,项目名称:oslo.service,代码行数:19,代码来源:test_wsgi.py

示例7: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, app, name, listen, max_url_len=None):
        super(WSGIService, self).__init__(CONF.senlin_api.threads)
        self.app = app
        self.name = name

        self.listen = listen

        self.servers = []

        for address in self.listen:
            host, port = netutils.parse_host_port(address)
            server = wsgi.Server(
                CONF, name, app,
                host=host,
                port=port,
                pool_size=CONF.senlin_api.threads,
                use_ssl=sslutils.is_enabled(CONF),
                max_url_len=max_url_len
            )

            self.servers.append(server) 
开发者ID:openstack,项目名称:senlin,代码行数:23,代码来源:service.py

示例8: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, name):
        self._host = CONF.api_migration_listen
        self._port = CONF.api_migration_listen_port

        if platform.system() == "Windows":
            self._workers = 1
        else:
            self._workers = (
                CONF.api_migration_workers or processutils.get_worker_count())

        self._loader = wsgi.Loader(CONF)
        self._app = self._loader.load_app(name)

        self._server = wsgi.Server(CONF,
                                   name,
                                   self._app,
                                   host=self._host,
                                   port=self._port) 
开发者ID:cloudbase,项目名称:coriolis,代码行数:20,代码来源:service.py

示例9: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, name, use_ssl=False):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param use_ssl: Wraps the socket in an SSL context if True.
        :returns: None
        """
        self.name = name
        self.app = app.load_app()
        self.workers = (CONF.api.api_workers or
                        processutils.get_worker_count())
        if self.workers and self.workers < 1:
            raise exception.ConfigInvalid(
                _("api_workers value of %d is invalid, "
                  "must be greater than 0.") % self.workers)

        self.server = wsgi.Server(CONF, self.name, self.app,
                                  host=CONF.api.host_ip,
                                  port=CONF.api.port,
                                  use_ssl=use_ssl) 
开发者ID:openstack,项目名称:cyborg,代码行数:22,代码来源:service.py

示例10: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self):
        self.app = app.setup_app()

        self.workers = CONF.api.api_workers
        if self.workers is not None and self.workers < 1:
            LOG.warning(
                "Value of config option api_workers must be integer "
                "greater than 1.  Input value ignored."
            )
            self.workers = None
        self.workers = self.workers or processutils.get_worker_count()

        self.server = wsgi.Server(
            cfg.CONF,
            "qinling_api",
            self.app,
            host=cfg.CONF.api.host,
            port=cfg.CONF.api.port,
            use_ssl=cfg.CONF.api.enable_ssl_api
        ) 
开发者ID:openstack,项目名称:qinling,代码行数:22,代码来源:service.py

示例11: __init__

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def __init__(self, name, loader=None):
        """Initialize, but do not start the WSGI server.

        :param name: The name of the WSGI server given to the loader.
        :param loader: Loads the WSGI application using the given name.
        :returns: None

        """
        self.name = name
        self.manager = self._get_manager()
        self.loader = loader or wsgi.Loader(CONF)
        if not rpc.initialized():
            rpc.init(CONF)
        self.app = self.loader.load_app(name)
        self.host = getattr(CONF, '%s_listen' % name, "0.0.0.0")
        self.port = getattr(CONF, '%s_listen_port' % name, 0)
        self.workers = getattr(CONF, '%s_workers' % name, None)
        self.use_ssl = getattr(CONF, '%s_use_ssl' % name, False)
        if self.workers is not None and self.workers < 1:
            LOG.warning(
                "Value of config option %(name)s_workers must be integer "
                "greater than 1.  Input value ignored.", {'name': name})
            # Reset workers to default
            self.workers = None
        self.server = wsgi.Server(
            CONF,
            name,
            self.app,
            host=self.host,
            port=self.port,
            use_ssl=self.use_ssl
        ) 
开发者ID:openstack,项目名称:manila,代码行数:34,代码来源:service.py

示例12: test_no_app

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_no_app(self):
        server = wsgi.Server(self.conf, "test_app", None)
        self.assertEqual("test_app", server.name) 
开发者ID:openstack,项目名称:oslo.service,代码行数:5,代码来源:test_wsgi.py

示例13: test_custom_max_header_line

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_custom_max_header_line(self):
        self.config(max_header_line=4096)  # Default value is 16384
        wsgi.Server(self.conf, "test_custom_max_header_line", None)
        self.assertEqual(eventlet.wsgi.MAX_HEADER_LINE,
                         self.conf.max_header_line) 
开发者ID:openstack,项目名称:oslo.service,代码行数:7,代码来源:test_wsgi.py

示例14: test_start_random_port

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_start_random_port(self):
        server = wsgi.Server(self.conf, "test_random_port", None,
                             host="127.0.0.1", port=0)
        server.start()
        self.assertNotEqual(0, server.port)
        server.stop()
        server.wait() 
开发者ID:openstack,项目名称:oslo.service,代码行数:9,代码来源:test_wsgi.py

示例15: test_start_random_port_with_ipv6

# 需要导入模块: from oslo_service import wsgi [as 别名]
# 或者: from oslo_service.wsgi import Server [as 别名]
def test_start_random_port_with_ipv6(self):
        server = wsgi.Server(self.conf, "test_random_port", None,
                             host="::1", port=0)
        server.start()
        self.assertEqual("::1", server.host)
        self.assertNotEqual(0, server.port)
        server.stop()
        server.wait() 
开发者ID:openstack,项目名称:oslo.service,代码行数:10,代码来源:test_wsgi.py


注:本文中的oslo_service.wsgi.Server方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。