本文整理汇总了Python中pulsar.send函数的典型用法代码示例。如果您正苦于以下问题:Python send函数的具体用法?Python send怎么用?Python send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了send函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpClass
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: setUpClass
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: 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())
示例4: testPasswordProtected
def testPasswordProtected(self):
yield self.spawn(password='bla', 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)
示例5: test_spawn_and_interact
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: __call__
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()
示例7: spawn_actor_from_actor
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
示例8: test_spawn_and_interact
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)
示例9: test_spawn_actor
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')
示例10: testPingArbiter
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')
示例11: test_multiple_execute
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: rpc_dispatch
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()
示例13: test_multiple_execute
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!')
示例14: app
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()
示例15: testSimpleSpawn
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)