twisted.spread.pb.Referenceable

Here are the examples of the python api twisted.spread.pb.Referenceable taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

Example 1

Project: feat Source File: manhole.py
    @classmethod
    def _build_remote_call(cls, function):
        f_name = "remote_%s" % function.__name__

        def wrapped(*args, **kwargs):
            res = function(*args, **kwargs)
            if isinstance(res, pb.Referenceable):
                return res
            else:
                #TODO: Serialize it
                return res

        wrapped.__name__ = f_name
        setattr(cls, f_name, wrapped)

Example 2

Project: nowin_core Source File: pb.py
def remoteCallback(func):
    class Callback(pb.Referenceable):

        def __call__(self, *args, **kwargs):
            return func(*args, **kwargs)

        def remote_call(self, event, data):
            try:
                return func(event, data)
            except Exception:
                logger = logging.getLogger(__name__)
                logger.error('Remote callback failed', exc_info=True)
    return Callback()

Example 3

Project: SubliminalCollaborator Source File: test_jelly.py
    def test_referenceable(self):
        """
        A L{pb.Referenceable} instance jellies to a structure which unjellies to
        a L{pb.RemoteReference}.  The C{RemoteReference} has a I{luid} that
        matches up with the local object key in the L{pb.Broker} which sent the
        L{Referenceable}.
        """
        ref = pb.Referenceable()
        jellyBroker = pb.Broker()
        jellyBroker.makeConnection(StringTransport())
        j = jelly.jelly(ref, invoker=jellyBroker)

        unjellyBroker = pb.Broker()
        unjellyBroker.makeConnection(StringTransport())

        uj = jelly.unjelly(j, invoker=unjellyBroker)
        self.assertIn(uj.luid, jellyBroker.localObjects)