本文整理汇总了Python中pulsar.Config.update方法的典型用法代码示例。如果您正苦于以下问题:Python Config.update方法的具体用法?Python Config.update怎么用?Python Config.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pulsar.Config
的用法示例。
在下文中一共展示了Config.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_config
# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import update [as 别名]
def create_config(cls, params, prefix=None, name=None):
"""Create a new :class:`.Config` container.
Invoked during initialisation, it overrides defaults
with ``params`` and apply the ``prefix`` to non global
settings.
"""
if isinstance(cls.cfg, Config):
cfg = cls.cfg.copy(name=name, prefix=prefix)
else:
cfg = cls.cfg.copy()
if name:
cfg[name] = name
if prefix:
cfg[prefix] = prefix
cfg = Config(**cfg)
cfg.update_settings()
cfg.update(params, True)
return cfg
示例2: __call__
# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import update [as 别名]
def __call__(self, actor=None):
'''Register this application with the (optional) calling ``actor``.
If an ``actor`` is available (either via the function argument or via
the :func:`~pulsar.async.actor.get_actor` function) it must be
:class:`.Arbiter`, otherwise this call is no-op.
If no actor is available, it means this application starts
pulsar engine by creating the :class:`.Arbiter` with its
:ref:`global settings <setting-section-global-server-settings>`
copied to the arbiter :class:`.Config` container.
:return: the ``start`` one time event fired once this application
has fired it.
'''
if actor is None:
actor = get_actor()
monitor = None
if actor and actor.is_arbiter():
monitor = actor.get_actor(self.name)
if monitor is None and (not actor or actor.is_arbiter()):
self.cfg.on_start()
self.logger = self.cfg.configured_logger()
if not actor: # arbiter not available
# This application is starts the arbiter
cfg = Config()
cfg.update(self.arbiter_params())
actor = pulsar.arbiter(cfg=cfg)
self.cfg.set('exc_id', actor.cfg.exc_id)
if self.on_config(actor) is not False:
start = Future(loop=actor._loop)
actor.bind_event('start', partial(self._add_monitor, start))
return start
else:
return
raise ImproperlyConfigured('Already started or not in arbiter domain')