当前位置: 首页>>代码示例>>Python>>正文


Python endpoint.RPCServer类代码示例

本文整理汇总了Python中pyon.net.endpoint.RPCServer的典型用法代码示例。如果您正苦于以下问题:Python RPCServer类的具体用法?Python RPCServer怎么用?Python RPCServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RPCServer类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_rpc_with_xn

    def test_rpc_with_xn(self):
        # get an xn to use for send/recv
        xn = self.container.ex_manager.create_xn_service('hello')
        self.addCleanup(xn.delete)

        # create an RPCServer for a hello service
        hs = HelloService()
        rpcs = RPCServer(from_name=xn, service=hs)

        # spawn the listener, kill on test exit (success/fail/error should cover?)
        gl_listen = spawn(rpcs.listen)
        def cleanup():
            rpcs.close()
            gl_listen.join(timeout=2)
            gl_listen.kill()
        self.addCleanup(cleanup)

        # wait for listen to be ready
        rpcs.get_ready_event().wait(timeout=5)

        # ok, now create a client using same xn
        hsc = HelloServiceClient(to_name=xn)

        # try to message it!
        ret = hsc.hello('hi there')

        # did we get back what we expected?
        self.assertEquals(ret, 'BACK:hi there')
开发者ID:j2project,项目名称:pyon,代码行数:28,代码来源:test_exchange.py

示例2: TransformBase

class TransformBase(SimpleProcess):
    '''
    TransformBase is the base class for all Transform Processes
    '''
    def __init__(self):
        super(TransformBase,self).__init__()
        self._stats = {} # Container for statistics information
    
    def on_start(self):
        '''
        Begins listening for incoming RPC calls.
        '''
        super(TransformBase,self).on_start()
        self._rpc_server = RPCServer(self, from_name=self.id)
        self._listener = gevent.spawn(self._rpc_server.listen)

    def on_quit(self):
        '''
        Closes the listener.
        '''
        self._rpc_server.close()
        self._listener.join(5)
        super(TransformBase, self).on_quit()

    def _stat(self):
        return self._stats

    @classmethod
    def stats(cls,pid):
        '''
        RPC Method for querying a Transform's internal statistics
        '''
        rpc_cli = RPCClient(to_name=pid)
        return rpc_cli.request({},op='_stat')
开发者ID:blazetopher,项目名称:coi-services,代码行数:34,代码来源:transform.py

示例3: test_rpc_server

    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"])
开发者ID:ooici-dm,项目名称:pyon,代码行数:26,代码来源:test_endpoint.py

示例4: __init__

    def __init__(self, process=None, routing_call=None, **kwargs):
        assert process
        self._process = process
        self._routing_call = routing_call

        # don't make people set service and process when they're almost always the same
        if not "service" in kwargs:
            kwargs = kwargs.copy()
            kwargs['service'] = process

        RPCServer.__init__(self, **kwargs)
开发者ID:j2project,项目名称:pyon,代码行数:11,代码来源:endpoint.py

示例5: on_start

 def on_start(self):
     '''
     Begins listening for incoming RPC calls.
     '''
     super(TransformBase,self).on_start()
     self._rpc_server = RPCServer(self, from_name=self.id)
     self._listener = gevent.spawn(self._rpc_server.listen)
开发者ID:blazetopher,项目名称:coi-services,代码行数:7,代码来源:transform.py

示例6: create_endpoint

 def create_endpoint(self, **kwargs):
     newkwargs = kwargs.copy()
     newkwargs['process'] = self._process
     newkwargs['routing_call'] = self._routing_call
     return RPCServer.create_endpoint(self, **newkwargs)
开发者ID:oldpatricka,项目名称:pyon,代码行数:5,代码来源:endpoint.py

示例7: __init__

 def __init__(self, process=None, routing_call=None, **kwargs):
     assert process
     self._process = process
     self._routing_call = routing_call
     RPCServer.__init__(self, **kwargs)
开发者ID:oldpatricka,项目名称:pyon,代码行数:5,代码来源:endpoint.py

示例8: BankService

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()


开发者ID:ateranishi,项目名称:pyon,代码行数:28,代码来源:_rpcs.py


注:本文中的pyon.net.endpoint.RPCServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。