本文整理汇总了Python中pyon.net.endpoint.RPCServer.listen方法的典型用法代码示例。如果您正苦于以下问题:Python RPCServer.listen方法的具体用法?Python RPCServer.listen怎么用?Python RPCServer.listen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.net.endpoint.RPCServer
的用法示例。
在下文中一共展示了RPCServer.listen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_rpc_server
# 需要导入模块: from pyon.net.endpoint import RPCServer [as 别名]
# 或者: from pyon.net.endpoint.RPCServer import listen [as 别名]
def test_rpc_server(self):
node = Mock(spec=NodeB)
svc = SimpleService()
rpcs = RPCServer(node=node, from_name="testrpc", service=svc)
# build a command object to be returned by the mocked channel
class FakeMsg(object):
def __init__(self):
self.named = ["ein", "zwei"]
cvalue = FakeMsg()
listen_channel_mock = self._setup_mock_channel(ch_type=ServerChannel)
rpcs.node.channel.return_value = listen_channel_mock
# tell our channel to return a mocked handler channel when accepted (listen() implementation detail)
listen_channel_mock.accept.return_value.__enter__.return_value = self._setup_mock_channel(
ch_type=ServerChannel.BidirAcceptChannel, value=cvalue, op="simple"
)
rpcs.listen()
# wait for first message to get passed in
ret = svc._ar.get()
self.assertIsInstance(ret, list)
self.assertEquals(ret, ["ein", "zwei"])
示例2: BankService
# 需要导入模块: from pyon.net.endpoint import RPCServer [as 别名]
# 或者: from pyon.net.endpoint.RPCServer import listen [as 别名]
node,iowat=make_node()
bs = BankService()
rpcs = RPCServer(node=node, name="bank", service=bs)
mooo=rpcs.listen()
gevent.joinall([mooo])
"""
"""
from pyon.container.cc import Container
cc=Container()
cc.start()
cc.start_rel_from_url('res/deploy/r2deploy.yml')
cc.serve_forever()
"""
from pyon.net.endpoint import RPCServer
from examples.service.hello_service import HelloService
hs=HelloService()
from pyon.net.messaging import make_node
n,io=make_node()
rpcs=RPCServer(service=hs, node=n, name=('qq', 'hello'))
rpcs.listen()