本文整理汇总了Python中pulsar.get_actor函数的典型用法代码示例。如果您正苦于以下问题:Python get_actor函数的具体用法?Python get_actor怎么用?Python get_actor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_actor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_registered
def test_registered(self):
'''Test the arbiter in its process domain'''
arbiter = pulsar.get_actor()
self.assertTrue(arbiter.is_arbiter())
self.assertTrue(arbiter.registered)
self.assertTrue('arbiter' in arbiter.registered)
self.assertTrue('test' in arbiter.registered)
示例2: test_actor_coverage
def test_actor_coverage(self):
'''test case for coverage'''
actor = pulsar.get_actor()
try:
yield send(send, 'sjdcbhjscbhjdbjsj', 'bla')
except CommandNotFound:
pass
示例3: testWorkerMonitor
def testWorkerMonitor(self):
worker = pulsar.get_actor()
monitor = worker.monitor
arbiter = worker.arbiter
mailbox = monitor.mailbox
self.assertEqual(mailbox, arbiter.mailbox)
self.assertTrue(mailbox.async)
示例4: test_ping_monitor
def test_ping_monitor(self):
worker = get_actor()
future = yield send('monitor', 'ping')
self.assertEqual(future, 'pong')
yield self.async.assertEqual(send(worker.monitor, 'ping'), 'pong')
response = yield send('monitor', 'notify', worker.info())
self.assertTrue(response <= time.time())
示例5: testTestSuiteMonitor
def testTestSuiteMonitor(self):
arbiter = pulsar.get_actor()
self.assertTrue(len(arbiter.monitors) >= 1)
monitor = arbiter.monitors['test']
app = monitor.app
self.assertTrue(isinstance(app, TestSuite))
self.assertFalse(monitor.cpubound)
示例6: test_suite_event_loop
def test_suite_event_loop(self):
'''Test event loop in test worker'''
worker = pulsar.get_actor()
loop = get_event_loop()
self.assertTrue(loop.is_running())
self.assertTrue(worker._loop.is_running())
self.assertNotEqual(worker._loop, loop)
示例7: run
def run(self, callable):
actor = get_actor()
if actor.is_monitor():
return callable(actor)
else:
# send the callable to the actor monitor
return actor.send(actor.monitor, 'run', callable)
示例8: get_clients
def get_clients():
actor = pulsar.get_actor()
clients = actor.params.clients
if clients is None:
clients = set()
actor.params.clients = clients
return clients
示例9: test_sorted_tags
def test_sorted_tags(self):
app = get_actor().app
loader = TestLoader(app.root_dir, app.cfg.modules, app.runner)
modules = list(loader.testmodules())
self.assertTrue(modules)
tags = [m[0] for m in modules]
self.assertEqual(tags, sorted(tags))
示例10: test_tasks
def test_tasks(self):
worker = pulsar.get_actor()
backend = worker.app.backend
self.assertTrue(worker.app.backend)
self.assertEqual(backend.name, worker.app.name)
self.assertEqual(len(backend.registry), 1)
self.assertTrue('test' in backend.registry)
示例11: testPing
def testPing(self):
c = self.client()
self.assertEqual(c.ping(), 'pong')
self.assertEqual(c.received, 1)
self.assertEqual(c.ping(), 'pong')
self.assertEqual(c.received, 2)
actor = pulsar.get_actor()
示例12: load_config
def load_config(self):
"""Load the application configuration from a file and/or
from the command line.
Called during application initialisation. The parameters
overriding order is the following:
* default parameters.
* the key-valued params passed in the initialisation.
* the parameters in the optional configuration file
* the parameters passed in the command line.
"""
# get the actor if available and override default cfg values with those
# from the actor
actor = get_actor()
if actor and actor.is_running():
# actor available and running.
# Unless argv is set, skip parsing
if self.argv is None:
self.console_parsed = False
# copy global settings
self.cfg.copy_globals(actor.cfg)
#
for name in list(self.cfg.params):
if name in self.cfg.settings:
value = self.cfg.params.pop(name)
if value is not None:
self.cfg.set(name, value)
# parse console args
if self.console_parsed:
self.cfg.parse_command_line(self.argv)
else:
self.cfg.params.update(self.cfg.import_from_module())
示例13: get_handler
def get_handler(self):
if self.handler is None:
self._worker = pulsar.get_actor()
if not self.cms:
self.cms = CMS(self)
async_middleware, wsgi = self._build_handler()
self.handler = wsgi
self.fire('on_loaded')
#
# Using a green pool
if self.green_pool:
from pulsar.apps.greenio.wsgi import GreenWSGI
wsgi = GreenWSGI(wsgi, self.green_pool)
async_middleware.append(wsgi)
else:
if self.config['THREAD_POOL']:
wsgi = middleware_in_executor(wsgi)
else:
wsgi = as_async_wsgi(wsgi)
async_middleware.append(wait_for_body_middleware)
async_middleware.append(wsgi)
self.handler = WsgiHandler(async_middleware, async=True)
return self.handler
示例14: __call__
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:
actor = pulsar.arbiter(cfg=self.cfg.clone())
else:
self.update_arbiter_params(actor)
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')
示例15: test_NOT_DONE
def test_NOT_DONE(self):
worker = pulsar.get_actor()
loop = pulsar.get_request_loop()
count = loop.num_loops
yield pulsar.NOT_DONE
self.assertEqual(loop.num_loops, count+1)
yield pulsar.NOT_DONE
self.assertEqual(loop.num_loops, count+2)