示例#1
0
 def setUpClass(cls):
     # Create the HttpBin server by sending this request to the arbiter
     from examples.proxyserver.manage import server as pserver
     from examples.httpbin import manage
     concurrency = cls.concurrency or cls.cfg.concurrency
     if cls.with_httpbin:
         server = manage.server
         if cls.with_tls:
             base_path = os.path.abspath(os.path.dirname(manage.__file__))
             key_file = os.path.join(base_path, 'server.key')
             cert_file = os.path.join(base_path, 'server.crt')
         else:
             key_file, cert_file = None, None
         s = server(bind='127.0.0.1:0', concurrency=concurrency,
                    name='httpbin-%s' % cls.__name__.lower(),
                    keep_alive=30, key_file=key_file, cert_file=cert_file,
                    workers=1)
         cfg = yield from send('arbiter', 'run', s)
         cls.app = cfg.app()
         bits = ('https' if cls.with_tls else 'http',) + cfg.addresses[0]
         # bits = (bits[0], 'dynquant.com', '8070')
         cls.uri = '%s://%s:%s/' % bits
     if cls.with_proxy:
         s = pserver(bind='127.0.0.1:0', concurrency=concurrency,
                     name='proxyserver-%s' % cls.__name__.lower())
         cfg = yield from send('arbiter', 'run', s)
         cls.proxy_app = cfg.app()
         cls.proxy_uri = 'http://{0}:{1}'.format(*cfg.addresses[0])
         # cls.proxy_uri = 'http://127.0.0.1:8080'
     cls._client = cls.client()
示例#2
0
文件: base.py 项目: msornay/pulsar
    def setUpClass(cls):
        # Create the HttpBin server by sending this request to the arbiter
        from examples.proxyserver.manage import server as pserver
        from examples.httpbin import manage

        concurrency = cls.concurrency or cls.cfg.concurrency
        if cls.with_httpbin:
            server = manage.server
            if cls.with_tls:
                base_path = os.path.abspath(os.path.dirname(manage.__file__))
                key_file = os.path.join(base_path, "server.key")
                cert_file = os.path.join(base_path, "server.crt")
            else:
                key_file, cert_file = None, None
            s = server(
                bind="127.0.0.1:0",
                concurrency=concurrency,
                name="httpbin-%s" % cls.__name__.lower(),
                keep_alive=30,
                key_file=key_file,
                cert_file=cert_file,
                workers=1,
            )
            cfg = yield from send("arbiter", "run", s)
            cls.app = cfg.app()
            bits = ("https" if cls.with_tls else "http",) + cfg.addresses[0]
            cls.uri = "%s://%s:%s/" % bits
        if cls.with_proxy:
            s = pserver(bind="127.0.0.1:0", concurrency=concurrency, name="proxyserver-%s" % cls.__name__.lower())
            cfg = yield from send("arbiter", "run", s)
            cls.proxy_app = cfg.app()
            cls.proxy_uri = "http://{0}:{1}".format(*cfg.addresses[0])
        cls._client = cls.client()
示例#3
0
 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())
示例#4
0
 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
0
文件: actor.py 项目: LoganTK/pulsar
 def test_spawn_and_interact(self):
     proxy = yield self.spawn_actor(name='pluto')
     self.assertEqual(proxy.name, 'pluto')
     yield self.async.assertEqual(send(proxy, 'ping'), 'pong')
     yield self.async.assertEqual(send(proxy, 'echo', 'Hello!'), 'Hello!')
     name, result = yield send(proxy, 'run', add, 1, 3)
     self.assertEqual(name, 'pluto')
     self.assertEqual(result, 4)
示例#6
0
文件: actor.py 项目: cyberj/pulsar
 def testPasswordProtected(self):
     yield self.spawn(password='******', name='pluto')
     proxy = self.a
     self.assertEqual(proxy.name, 'pluto')
     yield self.async.assertEqual(send(proxy, 'ping'), 'pong')
     yield self.async.assertRaises(pulsar.AuthenticationError,
                                   send(proxy, 'shutdown'))
     yield self.async.assertEqual(send(proxy, 'auth', 'bla'), True)
示例#7
0
 def test_spawn_and_interact(self):
     name = "pluto-%s" % self.concurrency
     proxy = yield from self.spawn_actor(name=name)
     self.assertEqual(proxy.name, name)
     yield from self.wait.assertEqual(send(proxy, "ping"), "pong")
     yield from self.wait.assertEqual(send(proxy, "echo", "Hello!"), "Hello!")
     n, result = yield from send(proxy, "run", add, 1, 3)
     self.assertEqual(n, name)
     self.assertEqual(result, 4)
示例#8
0
 def __call__(self, a=None):
     if a is None:
         a = yield spawn(name='greeter')
     if names:
         name = names.pop()
         send(a, 'greetme', {'name': name})
         self._loop.call_later(1, self, a)
     else:
         arbiter().stop()
示例#9
0
文件: actor.py 项目: Danzeer/pulsar
def spawn_actor_from_actor(actor, name):
    actor2 = yield from spawn(name=name)
    pong = yield from send(actor2, 'ping')
    assert pong == 'pong', 'no pong from actor'
    t1 = time()
    # cover the notify from a fron actor
    t2 = yield from send(actor2, 'notify', {})
    assert t2 >= t1

    return actor2.aid
示例#10
0
文件: actor.py 项目: LJS109/pulsar
 def test_spawn_and_interact(self):
     name = 'pluto-%s' % self.concurrency
     proxy = yield from self.spawn_actor(name=name)
     self.assertEqual(proxy.name, name)
     yield from self.async.assertEqual(send(proxy, 'ping'), 'pong')
     yield from self.async.assertEqual(send(proxy, 'echo', 'Hello!'),
                                       'Hello!')
     n, result = yield from send(proxy, 'run', add, 1, 3)
     self.assertEqual(n, name)
     self.assertEqual(result, 4)
示例#11
0
文件: me.py 项目: arhik/pulsar
 def test_multiple_execute(self):
     m = yield from multi_async((send('arbiter', 'run', wait, 1.2),
                                 send('arbiter', 'ping'),
                                 send('arbiter', 'echo', 'ciao!'),
                                 send('arbiter', 'run', wait, 2.1),
                                 send('arbiter', 'echo', 'ciao again!')))
     self.assertTrue(m[0] >= 1.1)
     self.assertEqual(m[1], 'pong')
     self.assertEqual(m[2], 'ciao!')
     self.assertTrue(m[3] >= 2.0)
     self.assertEqual(m[4], 'ciao again!')
示例#12
0
文件: me.py 项目: cyberj/pulsar
 def testPingArbiter(self):
     worker = pulsar.get_actor()
     yield self.async.assertEqual(send('arbiter', 'ping'), 'pong')
     yield self.async.assertEqual(send('arbiter', 'ping'), 'pong')
     result = worker.send('arbiter', 'notify', worker.info())
     if is_async(result):
         yield outcome
         result = outcome.result
     self.assertTrue(result>0)
     yield self.async.assertEqual(send('arbiter', 'ping'), 'pong')
     yield self.async.assertEqual(send('arbiter', 'echo', 'ciao'), 'ciao')
示例#13
0
文件: actor.py 项目: cyberj/pulsar
 def test_spawn_actor(self):
     '''Test spawning from actor domain.'''
     yield self.spawn(name='pippo')
     proxy = self.a
     self.assertEqual(proxy.name, 'pippo')
     # The current actor is linked with the actor just spawned
     actor = pulsar.get_actor()
     self.assertEqual(actor.get_actor(proxy.aid), proxy)
     yield self.async.assertEqual(send(proxy, 'ping'), 'pong')
     yield self.async.assertEqual(send(proxy, 'echo', 'Hello!'), 'Hello!')
     yield send(proxy, 'run', check_actor, 'pippo')
示例#14
0
文件: me.py 项目: cyberj/pulsar
 def test_multiple_execute(self):
     result1 = pulsar.send('arbiter', 'run', wait(0.2))
     result2 = pulsar.send('arbiter', 'ping')
     result3 = pulsar.send('arbiter', 'echo', 'ciao!')
     result4 = pulsar.send('arbiter', 'run', wait(0.1))
     result5 = pulsar.send('arbiter', 'echo', 'ciao again!')
     yield result5
     self.assertEqual(result1.result, 0.2)
     self.assertEqual(result2.result, 'pong')
     self.assertEqual(result3.result, 'ciao!')
     self.assertEqual(result4.result, 0.1)
     self.assertEqual(result5.result, 'ciao again!')
示例#15
0
 def rpc_dispatch(self, websocket, method, blob):
     """A generic dispatch function that sends commands to the
        Goblin application"""
     request_id = yield from pulsar.send(
         'goblin_server', 'add_task', method, blob)
     while True:
         blob = yield from pulsar.send(
             'goblin_server', 'read_response', request_id)
         if blob is None:
             break
         websocket.write(blob)
     websocket.write_close()
示例#16
0
文件: actor1.py 项目: Danzeer/pulsar
def app(arbiter):
    # Spawn a new actor
    proxy = yield from spawn(name='actor1')
    print(proxy.name)
    # Execute inner method in actor1
    result = yield from send(proxy, 'run', inner_method)
    print(result)

    yield from send(proxy, 'run', set_value, 10)
    value = yield from send(proxy, 'run', get_value)
    print(value)

    # Stop the application
    arbiter.stop()
示例#17
0
 def test_simple_spawn(self):
     """Test start and stop for a standard actor on the arbiter domain."""
     proxy = yield from self.spawn_actor(name="simple-actor-on-%s" % self.concurrency)
     arbiter = pulsar.get_actor()
     proxy_monitor = arbiter.get_actor(proxy.aid)
     self.assertEqual(proxy_monitor, proxy)
     yield from self.wait.assertEqual(send(proxy, "ping"), "pong")
     yield from self.wait.assertEqual(send(proxy.proxy, "echo", "Hello!"), "Hello!")
     # We call the ActorTestMixin.stop_actors method here, since the
     # ActorTestMixin.tearDown method is invoked on the test-worker domain
     # (here we are in the arbiter domain)
     yield from self.stop_actors(proxy)
     is_alive = yield from async_while(3, proxy_monitor.is_alive)
     self.assertFalse(is_alive)
示例#18
0
 def testSimpleSpawn(self):
     '''Test start and stop for a standard actor on the arbiter domain.'''
     proxy = yield self.spawn(name='simple-actor-on-%s' % self.concurrency)
     arbiter = pulsar.get_actor()
     proxy_monitor = arbiter.get_actor(proxy.aid)
     self.assertEqual(proxy_monitor, proxy)
     yield self.async.assertEqual(send(proxy, 'ping'), 'pong')
     yield self.async.assertEqual(send(proxy.proxy, 'echo', 'Hello!'),
                                  'Hello!')
     # We call the ActorTestMixin.stop_actors method here, since the
     # ActorTestMixin.tearDown method is invoked on the test-worker domain
     # (here we are in the arbiter domain)
     yield self.stop_actors(proxy)
     is_alive = yield async_while(3, proxy_monitor.is_alive)
     self.assertFalse(is_alive)
示例#19
0
文件: tests.py 项目: xmnlab/minilab
 def setUpClass(cls):
     s = server(bind='127.0.0.1:0', name=cls.__name__,
                concurrency=cls.concurrency)
     cls.app = yield send('arbiter', 'run', s)
     cls.uri = 'http://{0}:{1}'.format(*cls.app.address)
     cls.ws_uri = 'ws://{0}:{1}/data'.format(*cls.app.address)
     cls.ws_echo = 'ws://{0}:{1}/echo'.format(*cls.app.address)
示例#20
0
 def setUpClass(cls):
     name = 'calc_' + cls.concurrency
     s = server(bind='127.0.0.1:0', name=name, concurrency=cls.concurrency)
     cls.app = yield send('arbiter', 'run', s)
     cls.uri = 'http://{0}:{1}'.format(*cls.app.address)
     cls.p = rpc.JsonProxy(cls.uri, timeout=cls.rpc_timeout)
     cls.sync = rpc.JsonProxy(cls.uri, force_sync=True)
示例#21
0
文件: iostream.py 项目: cyberj/pulsar
 def setUpClass(cls):
     s = SocketServer(socket_server_factory=TestServerSocketServer,
                      name=cls.__name__.lower(), bind='127.0.0.1:0',
                      concurrency=cls.concurrency)
     outcome = pulsar.send('arbiter', 'run', s)
     yield outcome
     cls.server = outcome.result
示例#22
0
 def setUpClass(cls):
     name = 'calc_' + cls.concurrency
     s = server(bind='127.0.0.1:0', name=name, concurrency=cls.concurrency)
     cls.app_cfg = yield send('arbiter', 'run', s)
     cls.uri = 'http://{0}:{1}'.format(*cls.app_cfg.addresses[0])
     cls.p = rpc.JsonProxy(cls.uri, timeout=cls.rpc_timeout)
     cls.sync = rpc.JsonProxy(cls.uri, loop=new_event_loop())
示例#23
0
文件: actor.py 项目: LoganTK/pulsar
 def test_actor_coverage(self):
     '''test case for coverage'''
     actor = pulsar.get_actor()
     try:
         yield send(send, 'sjdcbhjscbhjdbjsj', 'bla')
     except CommandNotFound:
         pass
示例#24
0
 def setUpClass(cls):
     s = server(name=cls.name(),
                concurrency=cls.concurrency,
                bind='127.0.0.1:0')
     cls.app_cfg = yield from send('arbiter', 'run', s)
     cls.uri = 'http://{0}:{1}'.format(*cls.app_cfg.addresses[0])
     cls.client = HttpClient()
示例#25
0
文件: green.py 项目: arhik/pulsar
 def setUpClass(cls):
     s = server(name=cls.__name__.lower(), bind='127.0.0.1:0')
     cls.server_cfg = yield from send('arbiter', 'run', s)
     cls.client = Echo(cls.server_cfg.addresses[0])
     cls.green = EchoGreen(cls.server_cfg.addresses[0])
     cls.msg = b''.join((b'a' for x in range(2**13)))
     cls.pool = greenio.GreenPool()
示例#26
0
文件: actor.py 项目: LoganTK/pulsar
 def test_info(self):
     proxy = yield self.spawn_actor(name='pippo')
     self.assertEqual(proxy.name, 'pippo')
     info = yield send(proxy, 'info')
     self.assertTrue('actor' in info)
     ainfo = info['actor']
     self.assertEqual(ainfo['is_process'], self.concurrency == 'process')
示例#27
0
 def create_pulsar_store(cls):
     server = PulsarDS(name=cls.__name__.lower(),
                       bind='127.0.0.1:0',
                       concurrency=cls.cfg.concurrency,
                       redis_py_parser=cls.redis_py_parser)
     cls.pulsar_app_cfg = yield pulsar.send('arbiter', 'run', server)
     cls.pulsards_uri = 'pulsar://%s:%s' % cls.pulsar_app_cfg.addresses[0]
     cls.store = cls.create_store('%s/9' % cls.pulsards_uri)
示例#28
0
 def setUpClass(cls):
     s = server(bind='127.0.0.1:0', name=cls.__name__,
                concurrency=cls.concurrency, pyparser=cls.pyparser)
     cls.app_cfg = yield from send('arbiter', 'run', s)
     addr = cls.app_cfg.addresses[0]
     cls.uri = 'http://{0}:{1}'.format(*addr)
     cls.ws_uri = 'ws://{0}:{1}/data'.format(*addr)
     cls.ws_echo = 'ws://{0}:{1}/echo'.format(*addr)
示例#29
0
 def setUpClass(cls):
     s = server(bind='127.0.0.1:0', name=cls.__name__.lower(),
                concurrency=cls.concurrency)
     cls.app = yield send('arbiter', 'run', s)
     cls.uri = 'http://%s:%s' % cls.app.address
     cls.ws = 'ws://%s:%s/message' % cls.app.address
     cls.rpc = rpc.JsonProxy('%s/rpc' % cls.uri)
     cls.http = http.HttpClient()
示例#30
0
 def test_info(self):
     name = "pippo-%s" % self.concurrency
     proxy = yield from self.spawn_actor(name=name)
     self.assertEqual(proxy.name, name)
     info = yield from send(proxy, "info")
     self.assertTrue("actor" in info)
     ainfo = info["actor"]
     self.assertEqual(ainfo["is_process"], self.concurrency == "process")
示例#31
0
 def testTimeout(self):
     '''Test a bogus actor for timeout.'''
     arbiter = pulsar.get_actor()
     self.assertTrue(arbiter.is_arbiter())
     name = 'bogus-timeout-%s' % self.concurrency
     proxy = yield self.spawn_actor(name=name, timeout=1)
     self.assertEqual(proxy.name, name)
     self.assertTrue(proxy.aid in arbiter.managed_actors)
     proxy = arbiter.managed_actors[proxy.aid]
     yield send(proxy, 'run', cause_timeout)
     # The arbiter should soon start to stop the actor
     yield wait_for_stop(self, proxy.aid, True)
     #
     self.assertTrue(proxy.stopping_start)
     self.assertFalse(proxy.aid in arbiter.managed_actors)
示例#32
0
文件: test_app.py 项目: LJS109/pulsar
 def setUpClass(cls):
     cls.exc_id = gen_unique_id()[:8]
     name = cls.__name__.lower()
     argv = [
         __file__, 'pulse', '-b', '127.0.0.1:0', '--concurrency',
         cls.concurrency, '--exc-id', cls.exc_id, '--pulse-app-name', name,
         '--data-store', 'pulsar://127.0.0.1:6410/1'
     ]
     cls.app_cfg = yield from send('arbiter', 'run', start_server, name,
                                   argv)
     assert cls.app_cfg.exc_id == cls.exc_id, "Bad execution id"
     addr = cls.app_cfg.addresses[0]
     cls.uri = 'http://{0}:{1}'.format(*addr)
     cls.ws = 'ws://{0}:{1}/message'.format(*addr)
     cls.http = http.HttpClient()
示例#33
0
 def test_terminate(self):
     arbiter = pulsar.get_actor()
     self.assertTrue(arbiter.is_arbiter())
     name = 'bogus-term-%s' % self.concurrency
     proxy = yield from self.spawn_actor(name=name, timeout=1)
     self.assertEqual(proxy.name, name)
     self.assertTrue(proxy.aid in arbiter.managed_actors)
     proxy = arbiter.managed_actors[proxy.aid]
     #
     yield from send(proxy, 'run', cause_terminate)
     #
     # The arbiter should now terminate the actor
     yield from wait_for_stop(self, proxy.aid, True)
     #
     self.assertTrue(proxy.stopping_start)
     self.assertTrue(proxy in arbiter.terminated_actors)
示例#34
0
 def testTimeout(self):
     '''Test a bogus actor for timeout.'''
     arbiter = pulsar.get_actor()
     self.assertTrue(arbiter.is_arbiter())
     name = 'bogus-timeout-%s' % self.concurrency
     proxy = yield self.spawn(name=name, timeout=1)
     self.assertEqual(proxy.name, name)
     self.assertTrue(proxy.aid in arbiter.managed_actors)
     proxy = arbiter.managed_actors[proxy.aid]
     yield send(proxy, 'run', cause_timeout)
     # The arbiter should soon start to stop the actor
     interval = 2 * MONITOR_TASK_PERIOD
     yield pulsar.async_while(interval, lambda: not proxy.stopping_start)
     self.assertTrue(proxy.stopping_start)
     #
     yield pulsar.async_while(interval,
                              lambda: proxy.aid in arbiter.managed_actors)
     self.assertFalse(proxy.aid in arbiter.managed_actors)
示例#35
0
 def setUpClass(cls):
     # The name of the task queue application
     s = server(name=cls.name(),
                rpc_bind='127.0.0.1:0',
                concurrent_tasks=cls.concurrent_tasks,
                concurrency=cls.concurrency,
                rpc_concurrency=cls.concurrency,
                rpc_keep_alive=cls.rpc_timeout,
                task_backend=cls.task_backend(),
                script=__file__,
                schedule_periodic=cls.schedule_periodic)
     cls.apps = yield send('arbiter', 'run', s)
     # make sure the time out is high enough (bigger than test-timeout)
     cls.proxy = rpc.JsonProxy('http://%s:%s' % cls.apps[1].address,
                               timeout=cls.rpc_timeout)
     # Now flush the task queue
     backend = cls.apps[0].backend
     yield backend.flush()
示例#36
0
 def test_spawning_in_arbiter(self):
     arbiter = pulsar.get_actor()
     self.assertEqual(arbiter.name, 'arbiter')
     self.assertTrue(len(arbiter.monitors) >= 1)
     name = 'testSpawning-%s' % self.concurrency
     future = spawn(name=name, concurrency=self.concurrency)
     self.assertTrue(future.aid in arbiter.managed_actors)
     proxy = yield future
     self.assertEqual(future.aid, proxy.aid)
     self.assertEqual(proxy.name, name)
     self.assertTrue(proxy.aid in arbiter.managed_actors)
     self.assertEqual(proxy, arbiter.get_actor(proxy.aid))
     #
     # Stop the actor
     result = yield send(proxy, 'stop')
     self.assertEqual(result, None)
     #
     result = yield wait_for_stop(self, proxy.aid)
     self.assertEqual(result, None)
示例#37
0
 def start_store(url, workers=0, **kw):
     '''Equivalent to :func:`.create_store` for most cases excepts when the
     ``url`` is for a pulsar store not yet started.
     In this case, a :class:`.PulsarDS` is started.
     '''
     store = create_store(url, **kw)
     if store.name == 'pulsar':
         client = store.client()
         try:
             yield client.ping()
         except pulsar.ConnectionRefusedError:
             host = localhost(store._host)
             if not host:
                 raise
             cfg = yield send('arbiter', 'run', start_pulsar_ds,
                              host, workers)
             store._host = cfg.addresses[0]
             dns = store._buildurl()
             store = create_store(dns, **kw)
     coroutine_return(store)
示例#38
0
 def test_terminate(self):
     arbiter = pulsar.get_actor()
     self.assertTrue(arbiter.is_arbiter())
     name = 'bogus-term-%s' % self.concurrency
     proxy = yield self.spawn(name=name, timeout=1)
     self.assertEqual(proxy.name, name)
     self.assertTrue(proxy.aid in arbiter.managed_actors)
     proxy = arbiter.managed_actors[proxy.aid]
     #
     result = yield send(proxy, 'run', cause_terminate)
     #
     # The arbiter should soon start stop the actor
     interval = 3 * MONITOR_TASK_PERIOD
     yield pulsar.async_while(2 * MONITOR_TASK_PERIOD,
                              lambda: not proxy.stopping_start)
     self.assertTrue(proxy.stopping_start)
     #
     yield pulsar.async_while(1.5 * ACTOR_ACTION_TIMEOUT,
                              lambda: proxy.aid in arbiter.managed_actors)
     self.assertTrue(proxy in arbiter.terminated_actors)
     self.assertFalse(proxy.aid in arbiter.managed_actors)
示例#39
0
 def test_create_pid(self):
     proxy = yield from self.spawn_actor(name='pippo')
     info = yield from send(proxy, 'info')
     result = info['actor']
     self.assertTrue(result['is_process'])
     pid = result['process_id']
     #
     p = Pidfile()
     self.assertEqual(p.fname, None)
     self.assertEqual(p.pid, None)
     p.create(pid)
     self.assertTrue(p.fname)
     self.assertEqual(p.pid, pid)
     p1 = Pidfile(p.fname)
     self.assertRaises(RuntimeError, p1.create, p.pid + 1)
     #
     p1 = Pidfile('bla/ksdcskcbnskcdbskcbksdjcb')
     self.assertRaises(RuntimeError, p1.create, p.pid + 1)
     p1.unlink()
     p.unlink()
     self.assertFalse(os.path.exists(p.fname))
示例#40
0
 def test_spawn_from_actor(self):
     proxy = yield from self.spawn_actor(
         name='spawning-actor-%s' % self.concurrency)
     arbiter = pulsar.get_actor()
     self.assertTrue(repr(proxy).startswith('spawning-actor-'))
     self.assertEqual(proxy, proxy.proxy)
     proxy_monitor = arbiter.get_actor(proxy.aid)
     self.assertFalse(proxy != proxy_monitor)
     #
     # do the spawning
     name = 'spawned-actor-%s-from-actor' % self.concurrency
     aid = yield from send(proxy, 'run', spawn_actor_from_actor, name)
     self.assertTrue(aid)
     proxy_monitor2 = arbiter.get_actor(aid)
     self.assertEqual(proxy_monitor2.name, name)
     self.assertNotEquals(proxy_monitor, proxy_monitor2)
     #
     # stop them
     yield from self.stop_actors(proxy, proxy_monitor2)
     is_alive = yield from async_while(3, proxy_monitor.is_alive)
     self.assertFalse(is_alive)
     is_alive = yield from async_while(3, proxy_monitor2.is_alive)
     self.assertFalse(is_alive)
示例#41
0
 def test_config_command(self):
     proxy = yield from self.spawn_actor(name='actor-test-config-%s' %
                                         self.concurrency)
     arbiter = pulsar.get_actor()
     proxy_monitor = arbiter.get_actor(proxy.aid)
     result = yield from send(proxy, 'config', 'khjkh', 'name')
     self.assertEqual(result, None)
     result = yield from send(proxy, 'config', 'get', 'concurrency')
     self.assertEqual(result, self.concurrency)
     result = yield from send(proxy, 'config', 'get', 'concurrency', 'foo')
     self.assertEqual(result, None)
     #
     result = yield from send(proxy, 'config', 'set', 'max_requests', 1000,
                              1000)
     self.assertEqual(result, None)
     result = yield from send(proxy, 'config', 'set', 'max_requests', 1000)
     self.assertEqual(result, True)
     result = yield from send(proxy, 'config', 'get', 'max_requests')
     self.assertEqual(result, 1000)
     #
     yield from self.stop_actors(proxy)
     is_alive = yield from async_while(3, proxy_monitor.is_alive)
     self.assertFalse(is_alive)
示例#42
0
文件: utils.py 项目: devopsmi/pulsar
 def stop_actors(self, *args):
     all = args or self.all_spawned
     return as_gather(*[send(a, 'stop') for a in all])
示例#43
0
 def tearDownClass(cls):
     coros = [
         send('arbiter', 'kill_actor', a.name)
         for a in (cls.tq_app, cls.rpc) if a is not None
     ]
     return asyncio.gather(*coros)
示例#44
0
文件: me.py 项目: japaks/pulsar
 def testInline(self):
     val = yield 3
     self.assertEqual(val, 3)
     future = yield send('monitor', 'ping')
     self.assertEqual(future, 'pong')
示例#45
0
 def tearDownClass(cls):
     cmnds = [send('arbiter', 'kill_actor', a.name) for a in cls.apps]
     yield multi_async(cmnds)
示例#46
0
 def rpc_kill_actor(self, request, aid):
     '''Kill the actor with id equal to *aid*.'''
     return pulsar.send('arbiter', 'kill_actor', aid)
示例#47
0
 def setUpClass(cls):
     app = DiningPhilosophers(name='plato', concurrency=cls.concurrency)
     cls.app_cfg = yield from send('arbiter', 'run', app)
示例#48
0
文件: sync.py 项目: japaks/pulsar
 def tearDownClass(cls):
     if cls.server:
         yield pulsar.send('arbiter', 'kill_actor', cls.server.name)
示例#49
0
 def __call__(self, *args, **kwargs):
     return send(self.remote.proxy, 'remote_call', self.remote.__class__,
                 self.name, args, kwargs)
示例#50
0
 def test_get_application(self):
     proxy = yield from self.spawn_actor(
         name='actor-test-get-application-%s' % self.concurrency)
     cfg = yield from send(proxy, 'run', get_test)
     self.assertTrue(cfg)
     self.assertEqual(cfg.name, 'test')
示例#51
0
 def tearDownClass(cls):
     if cls.server_cfg:
         return send('arbiter', 'kill_actor', cls.server_cfg.name)
示例#52
0
 def stop_actors(self, *args):
     all = args or self.all_spawned
     return multi_async([send(a, 'stop') for a in all])
示例#53
0
 def tearDownClass(cls):
     if cls.app is not None:
         yield send('arbiter', 'kill_actor', cls.app.name)
示例#54
0
文件: tests.py 项目: japaks/pulsar
 def tearDownClass(cls):
     if cls.app:
         return send('arbiter', 'kill_actor', cls.app.name)
示例#55
0
 def tearDownClass(cls):
     if cls.app_cfg is not None:
         return send('arbiter', 'kill_actor', cls.app_cfg.name)
示例#56
0
文件: sync.py 项目: japaks/pulsar
 def setUpClass(cls):
     s = server(name=cls.__name__.lower(),
                bind='127.0.0.1:0',
                concurrency=get_actor().cfg.concurrency)
     cls.server = yield pulsar.send('arbiter', 'run', s)
     cls.client = Echo(force_sync=True)
示例#57
0
 def setUpClass(cls):
     s = server(name=cls.__name__.lower(), bind='127.0.0.1:0',
                concurrency=cls.concurrency)
     cls.server = yield pulsar.send('arbiter', 'run', s)
示例#58
0
文件: tests.py 项目: robgil/pulsar
 def setUpClass(cls):
     cls.app_cfg = yield send('arbiter', 'run', start)
示例#59
0
 def setUpClass(cls):
     s = server(name=cls.__name__.lower(),
                bind='127.0.0.1:0',
                concurrency=cls.concurrency)
     cls.server_cfg = yield send('arbiter', 'run', s)
     cls.client = Echo(cls.server_cfg.addresses[0])
示例#60
0
文件: me.py 项目: japaks/pulsar
 def test_unknown_send_target(self):
     # The target does not exists
     future = pulsar.send('vcghdvchdgcvshcd',
                          'ping').add_both(lambda r: [r])
     yield future
     self.assertTrue(is_failure(future.result[0]))