本文整理汇总了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)
示例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)
示例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)
示例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)
示例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()
示例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()
示例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)
示例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)
示例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)
示例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
)
示例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
)
示例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)
示例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)
示例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()
示例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()