本文整理汇总了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)
示例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')
示例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)
示例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)
示例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
示例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)
示例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)