本文整理汇总了Python中sandesh_http.SandeshHttp.stop_http_server方法的典型用法代码示例。如果您正苦于以下问题:Python SandeshHttp.stop_http_server方法的具体用法?Python SandeshHttp.stop_http_server怎么用?Python SandeshHttp.stop_http_server使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sandesh_http.SandeshHttp
的用法示例。
在下文中一共展示了SandeshHttp.stop_http_server方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Sandesh
# 需要导入模块: from sandesh_http import SandeshHttp [as 别名]
# 或者: from sandesh_http.SandeshHttp import stop_http_server [as 别名]
class Sandesh(object):
_DEFAULT_LOG_FILE = sand_logger.SandeshLogger._DEFAULT_LOG_FILE
_DEFAULT_SYSLOG_FACILITY = (
sand_logger.SandeshLogger._DEFAULT_SYSLOG_FACILITY)
class SandeshRole:
INVALID = 0
GENERATOR = 1
COLLECTOR = 2
# end class SandeshRole
def __init__(self):
self._context = ''
self._scope = ''
self._module = ''
self._source = ''
self._node_type = ''
self._instance_id = ''
self._timestamp = 0
self._versionsig = 0
self._type = 0
self._hints = 0
self._client_context = ''
self._client = None
self._role = self.SandeshRole.INVALID
self._logger = None
self._level = SandeshLevel.INVALID
self._category = ''
self._send_queue_enabled = True
self._http_server = None
self._connect_to_collector = True
# end __init__
# Public functions
def init_generator(self, module, source, node_type, instance_id,
collectors, client_context,
http_port, sandesh_req_uve_pkg_list=None,
discovery_client=None, connect_to_collector=True,
logger_class=None, logger_config_file=None,
host_ip='127.0.0.1', alarm_ack_callback=None):
self._role = self.SandeshRole.GENERATOR
self._module = module
self._source = source
self._node_type = node_type
self._instance_id = instance_id
self._host_ip = host_ip
self._client_context = client_context
self._collectors = collectors
self._connect_to_collector = connect_to_collector
self._rcv_queue = WorkQueue(self._process_rx_sandesh)
self._send_level = SandeshLevel.INVALID
self._init_logger(module, logger_class=logger_class,
logger_config_file=logger_config_file)
self._logger.info('SANDESH: CONNECT TO COLLECTOR: %s',
connect_to_collector)
from sandesh_stats import SandeshMessageStatistics
self._msg_stats = SandeshMessageStatistics()
self._trace = trace.Trace()
self._sandesh_request_map = {}
self._alarm_ack_callback = alarm_ack_callback
self._uve_type_maps = SandeshUVETypeMaps(self._logger)
if sandesh_req_uve_pkg_list is None:
sandesh_req_uve_pkg_list = []
# Initialize the request handling
# Import here to break the cyclic import dependency
import sandesh_req_impl
sandesh_req_impl = sandesh_req_impl.SandeshReqImpl(self)
sandesh_req_uve_pkg_list.append('pysandesh.gen_py')
for pkg_name in sandesh_req_uve_pkg_list:
self._create_sandesh_request_and_uve_lists(pkg_name)
self._gev_httpd = None
if http_port != -1:
self._http_server = SandeshHttp(
self, module, http_port, sandesh_req_uve_pkg_list)
self._gev_httpd = gevent.spawn(self._http_server.start_http_server)
primary_collector = None
secondary_collector = None
if self._collectors is not None:
if len(self._collectors) > 0:
primary_collector = self._collectors[0]
if len(self._collectors) > 1:
secondary_collector = self._collectors[1]
if self._connect_to_collector:
self._client = SandeshClient(
self, primary_collector, secondary_collector,
discovery_client)
self._client.initiate()
# end init_generator
def uninit(self):
self.kill_httpd()
def kill_httpd(self):
if self._gev_httpd:
try:
self._http_server.stop_http_server()
self._http_server = None
gevent.sleep(0)
self._gev_httpd.kill()
#.........这里部分代码省略.........