本文整理匯總了Python中oslo_service.service.Service方法的典型用法代碼示例。如果您正苦於以下問題:Python service.Service方法的具體用法?Python service.Service怎麽用?Python service.Service使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類oslo_service.service
的用法示例。
在下文中一共展示了service.Service方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def __init__(self, host, binary, topic, manager, report_interval=None,
periodic_interval=None, periodic_fuzzy_delay=None,
service_name=None, coordination=False, *args, **kwargs):
super(Service, self).__init__()
if not rpc.initialized():
rpc.init(CONF)
self.host = host
self.binary = binary
self.topic = topic
self.manager_class_name = manager
manager_class = importutils.import_class(self.manager_class_name)
self.manager = manager_class(host=self.host,
service_name=service_name,
*args, **kwargs)
self.availability_zone = self.manager.availability_zone
self.report_interval = report_interval
self.periodic_interval = periodic_interval
self.periodic_fuzzy_delay = periodic_fuzzy_delay
self.saved_args, self.saved_kwargs = args, kwargs
self.timers = []
self.coordinator = coordination
示例2: stop
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def stop(self):
# Try to shut the connection down, but if we get any sort of
# errors, go ahead and ignore them.. as we're shutting down anyway
try:
self.rpcserver.stop()
except Exception:
pass
for x in self.timers:
try:
x.stop()
except Exception:
pass
if self.coordinator:
try:
coordination.LOCK_COORDINATOR.stop()
except Exception:
LOG.exception("Unable to stop the Tooz Locking "
"Coordinator.")
self.timers = []
super(Service, self).stop()
示例3: test_parent_graceful_shutdown
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def test_parent_graceful_shutdown(self, mock_rpc, mock_rpc_init,
mock_stop):
serv = service.Service(self.host,
self.binary,
self.topic,
'masakari.tests.unit.test_service.FakeManager')
serv.manager = mock.Mock()
serv.manager.service_name = self.topic
serv.start()
serv.stop()
serv.rpcserver.start.assert_called_once_with()
serv.rpcserver.stop.assert_called_once_with()
mock_stop.assert_called_once_with()
示例4: start
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def start(self):
super(Service, self).start()
self.conn = create_connection()
LOG.debug("Creating Consumer connection for Service %s",
self.topic)
endpoints = [self.manager]
self.conn.create_consumer(self.topic, endpoints)
# Hook to allow the manager to do other initializations after
# the rpc connection is created.
if callable(getattr(self.manager, 'initialize_service_hook', None)):
self.manager.initialize_service_hook(self)
# Consume from all consumers in threads
self.conn.consume_in_threads()
示例5: stop
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def stop(self):
try:
self.rpcserver.stop()
self.rpcserver.wait()
except Exception as e:
LOG.exception('Service error occurred when stopping the '
'RPC server. Error: %s', e)
try:
self.manager.del_host()
except Exception as e:
LOG.exception('Service error occurred when cleaning up '
'the RPC manager. Error: %s', e)
super(RPCService, self).stop(graceful=True)
LOG.info('Stopped RPC server for service %(service)s on host '
'%(host)s.',
{'service': manager.MANAGER_TOPIC, 'host': self.host})
示例6: __init__
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def __init__(self, host, binary, topic, manager, report_interval=None,
periodic_interval=None, periodic_fuzzy_delay=None,
service_name=None, *args, **kwargs):
super(Service, self).__init__()
rpc.init(CONF)
self.host = host
self.binary = binary
self.topic = topic
self.manager_class_name = manager
manager_class = importutils.import_class(self.manager_class_name)
self.manager = manager_class(host=self.host,
service_name=service_name,
*args, **kwargs)
self.report_interval = report_interval
self.periodic_interval = periodic_interval
self.periodic_fuzzy_delay = periodic_fuzzy_delay
self.basic_config_check()
self.saved_args, self.saved_kwargs = args, kwargs
self.timers = []
self.rpcserver = None
示例7: start
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def start(self):
super(Service, self).start()
self.conn = Connection()
LOG.debug("Creating Consumer connection for Service %s",
self.topic)
endpoints = [self.manager]
self.conn.create_consumer(self.topic, endpoints)
# Hook to allow the manager to do other initializations after
# the rpc connection is created.
if callable(getattr(self.manager, 'initialize_service_hook', None)):
self.manager.initialize_service_hook(self)
# Consume from all consumers in threads
self.conn.consume_in_threads()
示例8: __init__
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def __init__(self, topic, server, endpoints, binary):
super(Service, self).__init__()
serializer = _init_serializer()
transport = messaging.get_rpc_transport(CONF)
access_policy = dispatcher.DefaultRPCAccessPolicy
# TODO(asalkeld) add support for version='x.y'
target = messaging.Target(topic=topic, server=server)
self.endpoints = endpoints
self._server = messaging.get_rpc_server(transport, target, endpoints,
executor='eventlet',
serializer=serializer,
access_policy=access_policy)
self.binary = binary
profiler.setup(binary, CONF.host)
示例9: stop
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def stop(self):
if self._server:
self._server.stop()
self._server.wait()
super(Service, self).stop()
示例10: start
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def start(self):
LOG.info("Service '%s' starting", self.__class__.__name__)
super(KuryrK8sService, self).start()
if not CONF.kubernetes.controller_ha:
LOG.info('Running in non-HA mode, starting watcher immediately.')
self.watcher.start()
self.pool_driver.sync_pools()
else:
LOG.info('Running in HA mode, watcher will be started later.')
f = functools.partial(self.run_periodic_tasks, None)
self.tg.add_timer(1, f)
self.health_manager.run()
LOG.info("Service '%s' started", self.__class__.__name__)
示例11: wait
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def wait(self):
super(KuryrK8sService, self).wait()
LOG.info("Service '%s' stopped", self.__class__.__name__)
示例12: stop
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def stop(self, graceful=False):
LOG.info("Service '%s' stopping", self.__class__.__name__)
self.watcher.stop()
super(KuryrK8sService, self).stop(graceful)
示例13: __init__
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def __init__(self, name, threads=None):
threads = threads or 1000
super(Service, self).__init__(threads)
self.name = name
self.host = CONF.host
policy.init()
if not rpc.initialized():
rpc.init(CONF)
示例14: start
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def start(self):
LOG.info('Starting %(name)s service (version: %(version)s)',
{
'name': self.name,
'version': version.version_info.version_string()
})
super(Service, self).start()
示例15: stop
# 需要導入模塊: from oslo_service import service [as 別名]
# 或者: from oslo_service.service import Service [as 別名]
def stop(self, graceful=True):
LOG.info('Stopping %(name)s service', {'name': self.name})
super(Service, self).stop(graceful)