[Twisted-Python] Perspective Broker system into a TCP Listener

Christian Espinoza chespinoza at gmail.com
Fri Feb 8 08:50:14 EST 2013


Hello, I'm trying to understand how can I use Perspective Broker to send
some data getted from a TCP listener to another process...

I can't figure out how to get it....


from twisted.internet import protocol, reactor
from twisted.python import log

from twisted.spread import pb


class Service(protocol.Protocol):
    extra = {}
  def dataReceived(self, data):
  extra = doSomething(data)
  #SEND extra TO ANOTHER PROCESS -- FAILED CODE
        factory = pb.PBClientFactory()
        reactor.connectTCP("localhost", 8798, factory)
        root = factory.getRootObject()

        def got_root(root):
          rc = root.callRemote("get", data)
            def got_value(v):
              print v
                reactor.stop()
            rc.addCallback(got_value)

        root.addCallback(got_root)
        reactor.run()
                ....

class ServerFactory(protocol.Factory):
    def buildProtocol(self, addr):
        return Service()

reactor.listenTCP(8797, ServerFactory())
reactor.run()

This testing code fails, I know I'm wrong, please could somebody help me to
understand and get it?
Thanks in advance.
Christian Espinoza.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20130208/cf5aeb5b/attachment.htm 


More information about the Twisted-Python mailing list