[Twisted-Python] Problem combining pb and spawnProcess

Stefan Fleiter sf.lists at web.de
Wed Jun 11 07:11:28 MDT 2003


#!/usr/bin/env python

from twisted.spread import pb
from twisted.internet import reactor

class MessageReceiver(pb.Referenceable):
     def remote_receiveMessage(self, message):
         print 'server echoed:', message, '<br>'


class CComHandler:
     def __init__(self, mr):
         self.mr = mr
         self.remRef = None
     def gotObject(self, object):
         self.remRef = object
         mydef = self.remRef.callRemote("takeMessageReceiver", self.mr)
         mydef.addCallbacks(self.gaveMr, self.gotErr)
     def gaveMr(self, reason):
         print 'gave MessageReceiver'
         mydef = self.remRef.callRemote("dir")
         mydef.addCallbacks(self.calledDir, self.gotErr)
     def calledDir(self, reason):
         print 'called dir remotely<br>'
     def gotErr(self, reason):
         print 'Error: %s<br>' % reason
         reactor.stop()


def doDir():
     mr = MessageReceiver()
     c = CComHandler(mr)
     pb.getObjectAt("localhost", 8848, 30).addCallback(c.gotObject)
     reactor.run()

if __name__ == "__main__":
     machine = 'mymachine'
     packages = [('myPackage', 'myVersion')]
     doDir()





More information about the Twisted-Python mailing list