本文整理汇总了Python中pyon.core.bootstrap.CFG.copy方法的典型用法代码示例。如果您正苦于以下问题:Python CFG.copy方法的具体用法?Python CFG.copy怎么用?Python CFG.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.core.bootstrap.CFG
的用法示例。
在下文中一共展示了CFG.copy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _register_config
# 需要导入模块: from pyon.core.bootstrap import CFG [as 别名]
# 或者: from pyon.core.bootstrap.CFG import copy [as 别名]
def _register_config(self):
self.register("/Config", "CFG", **CFG.copy())
示例2: spawn_process
# 需要导入模块: from pyon.core.bootstrap import CFG [as 别名]
# 或者: from pyon.core.bootstrap.CFG import copy [as 别名]
def spawn_process(self, name=None, module=None, cls=None, config=None, process_id=None):
"""
Spawn a process within the container. Processes can be of different type.
"""
if process_id and not is_valid_identifier(process_id, ws_sub='_'):
raise BadRequest("Given process_id %s is not a valid identifier" % process_id)
# Generate a new process id if not provided
# TODO: Ensure it is system-wide unique
process_id = process_id or "%s.%s" % (self.container.id, self.proc_id_pool.get_id())
log.debug("ProcManager.spawn_process(name=%s, module.cls=%s.%s, config=%s) as pid=%s", name, module, cls, config, process_id)
process_cfg = CFG.copy()
if config:
# Use provided config. Must be dict or DotDict
if not isinstance(config, DotDict):
config = DotDict(config)
dict_merge(process_cfg, config, inplace=True)
if self.container.spawn_args:
# Override config with spawn args
dict_merge(process_cfg, self.container.spawn_args, inplace=True)
#log.debug("spawn_process() pid=%s process_cfg=%s", process_id, process_cfg)
# PROCESS TYPE. Determines basic process context (messaging, service interface)
# One of: service, stream_process, agent, simple, immediate
service_cls = named_any("%s.%s" % (module, cls))
process_type = get_safe(process_cfg, "process.type") or getattr(service_cls, "process_type", "service")
service_instance = None
try:
# spawn service by type
if process_type == "service":
service_instance = self._spawn_service_process(process_id, name, module, cls, process_cfg)
elif process_type == "stream_process":
service_instance = self._spawn_stream_process(process_id, name, module, cls, process_cfg)
elif process_type == "agent":
service_instance = self._spawn_agent_process(process_id, name, module, cls, process_cfg)
elif process_type == "standalone":
service_instance = self._spawn_standalone_process(process_id, name, module, cls, process_cfg)
elif process_type == "immediate":
service_instance = self._spawn_immediate_process(process_id, name, module, cls, process_cfg)
elif process_type == "simple":
service_instance = self._spawn_simple_process(process_id, name, module, cls, process_cfg)
else:
raise BadRequest("Unknown process type: %s" % process_type)
service_instance._proc_type = process_type
self._register_process(service_instance, name)
service_instance.errcause = "OK"
log.info("ProcManager.spawn_process: %s.%s -> pid=%s OK", module, cls, process_id)
if process_type == 'immediate':
log.info('Terminating immediate process: %s', service_instance.id)
self.terminate_process(service_instance.id)
return service_instance.id
except Exception:
errcause = service_instance.errcause if service_instance else "instantiating service"
log.exception("Error spawning %s %s process (process_id: %s): %s", name, process_type, process_id, errcause)
raise