当前位置: 首页>>代码示例>>Python>>正文


Python Config.set方法代码示例

本文整理汇总了Python中pulsar.Config.set方法的典型用法代码示例。如果您正苦于以下问题:Python Config.set方法的具体用法?Python Config.set怎么用?Python Config.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pulsar.Config的用法示例。


在下文中一共展示了Config.set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testBadConfig

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
 def testBadConfig(self):
     cfg = Config()
     self.assertEqual(cfg.import_from_module('foo/bla/cnkjnckjcn.py'), [])
     cfg.set('config', None)
     self.assertEqual(cfg.config, None)
     cfg = Config(exclude=['config'])
     self.assertEqual(cfg.config, None)
开发者ID:cyberj,项目名称:pulsar,代码行数:9,代码来源:config.py

示例2: testSystem

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
 def testSystem(self):
     from pulsar import system
     cfg = Config()
     self.assertEqual(cfg.uid, system.get_uid())
     self.assertEqual(cfg.gid, system.get_gid())
     self.assertEqual(cfg.proc_name, 'pulsar')
     cfg.set('process_name', 'bla')
     self.assertEqual(cfg.proc_name, 'bla')
开发者ID:Danzeer,项目名称:pulsar,代码行数:10,代码来源:config.py

示例3: testFunction

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
 def testFunction(self):
     cfg = Config()
     worker = get_actor()
     self.assertTrue(cfg.post_fork)
     self.assertEqual(cfg.post_fork(worker), None)
     cfg.set('post_fork', post_fork)
     self.assertEqual(cfg.post_fork(worker), worker)
     cfg1 = pickle.loads(pickle.dumps(cfg))
     self.assertEqual(cfg1.post_fork(worker), worker)
开发者ID:Danzeer,项目名称:pulsar,代码行数:11,代码来源:config.py

示例4: testFunction

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
 def testFunction(self):
     cfg = Config()
     worker = get_actor()
     self.assertTrue(cfg.arbiter_task)
     self.assertEqual(cfg.arbiter_task(worker), None)
     cfg.set('arbiter_task', worker_task)
     self.assertEqual(cfg.arbiter_task(worker), worker)
     cfg1 = pickle.loads(pickle.dumps(cfg))
     self.assertEqual(cfg1.arbiter_task(worker), worker)
开发者ID:cyberj,项目名称:pulsar,代码行数:11,代码来源:config.py

示例5: _spawn_actor

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
def _spawn_actor(cls, monitor, cfg=None, name=None, aid=None, **kw):
    # Internal function which spawns a new Actor and return its
    # ActorProxyMonitor.
    # *cls* is the Actor class
    # *monitor* can be either the ariber or a monitor
    kind = None
    if issubclass(cls, PoolMixin):
        kind = 'monitor'
    if monitor:
        params = monitor.actorparams()
        name = params.pop('name', name)
        aid = params.pop('aid', aid)
        cfg = params.pop('cfg', cfg)

    # get config if not available
    if cfg is None:
        if monitor:
            cfg = monitor.cfg.copy()
        else:
            cfg = Config()

    if not monitor:  # monitor not available, this is the arbiter
        if kind != 'monitor':
            raise TypeError('class %s not a valid monitor' % cls)
        kind = 'arbiter'
        params = {}
        if not cfg.exc_id:
            if not aid:
                aid = gen_unique_id()[:8]
            cfg.set('exc_id', aid)
    #
    for key, value in iteritems(kw):
        if key in cfg.settings:
            cfg.set(key, value)
        else:
            params[key] = value
    #
    if monitor:
        if not kind:
            if not issubclass(cls, Actor):
                raise TypeError('Class %s not a valid actor.' % cls)
            kind = cfg.concurrency
    if not kind:
        raise TypeError('Cannot spawn class %s. not a valid concurrency.'
                        % cls)
    actor_proxy = concurrency(kind, cls, monitor, cfg, name=name,
                              aid=aid, **params)
    # Add to the list of managed actors if this is a remote actor
    if isinstance(actor_proxy, Actor):
        return actor_proxy
    else:
        actor_proxy.monitor = monitor
        monitor.managed_actors[actor_proxy.aid] = actor_proxy
        future = actor_proxy_future(actor_proxy)
        actor_proxy.start()
        return future
开发者ID:Ghost-script,项目名称:dyno-chat,代码行数:58,代码来源:monitor.py

示例6: test_methods

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
 def test_methods(self):
     cfg = Config()
     self.assertEqual(cfg.get('sdjcbsjkbcd', 'ciao'), 'ciao')
     d = dict(cfg.items())
     self.assertEqual(len(d), len(cfg))
     sett = cfg.get('debug')
     self.assertTrue(str(sett))
     self.assertEqual(cfg.settings['debug'].default, False)
     cfg.set('debug', True, default=True)
     self.assertEqual(cfg.debug, True)
     self.assertEqual(cfg.settings['debug'].default, True)
开发者ID:Danzeer,项目名称:pulsar,代码行数:13,代码来源:config.py

示例7: _spawn_actor

# 需要导入模块: from pulsar import Config [as 别名]
# 或者: from pulsar.Config import set [as 别名]
def _spawn_actor(kind, monitor, cfg=None, name=None, aid=None, **kw):
    # Internal function which spawns a new Actor and return its
    # ActorProxyMonitor.
    # *cls* is the Actor class
    # *monitor* can be either the arbiter or a monitor
    if monitor:
        params = monitor.actorparams()
        name = params.pop('name', name)
        aid = params.pop('aid', aid)
        cfg = params.pop('cfg', cfg)

    # get config if not available
    if cfg is None:
        if monitor:
            cfg = monitor.cfg.copy()
        else:
            cfg = Config()

    if not aid:
        aid = create_aid()

    if not monitor:  # monitor not available, this is the arbiter
        assert kind == 'arbiter'
        name = kind
        params = {}
        if not cfg.exc_id:
            cfg.set('exc_id', aid)
    #
    for key, value in kw.items():
        if key in cfg.settings:
            cfg.set(key, value)
        else:
            params[key] = value
    #
    if monitor:
        kind = kind or cfg.concurrency
    if not kind:
        raise TypeError('Cannot spawn')

    maker = concurrency_models.get(kind)
    if maker:
        c = maker()
        return c.make(kind, cfg, name, aid, monitor=monitor, **params)
    else:
        raise ValueError('Concurrency %s not supported in pulsar' % kind)
开发者ID:juanignaciocatalano,项目名称:pulsar,代码行数:47,代码来源:concurrency.py


注:本文中的pulsar.Config.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。