c4ec28c6 |
wisted.spread import pb, jelly
from twisted.python import log
from twisted.internet import reactor
class LilyPond:
|
4e75ae60 |
def setStuff(self, color, numFrogs):
self.color = color
self.numFrogs = numFrogs
def countFrogs(self):
print "%d frogs" % self.numFrogs
|
c4ec28c6 |
class CopyPond(LilyPond, pb.Copyable): pass
class Sender:
|
4e75ae60 |
def __init__(self, pond):
self.pond = pond
def got_obj(self, remote):
self.remote = remote
d = remote.callRemote("takePond", self.pond)
d.addCallback(self.ok).addErrback(self.notOk)
def ok(self, response):
print "pond arrived", response
reactor.stop()
def notOk(self, failure):
print "error during takePond:"
if failure.type == jelly.InsecureJelly:
print " InsecureJelly"
else:
print failure
reactor.stop()
return None
|
c4ec28c6 |
def main():
|
4e75ae60 |
from copy_sender import CopyPond # so it's not __main__.CopyPond
pond = CopyPond()
pond.setStuff("green", 7)
pond.countFrogs()
# class name:
print ".".join([pond.__class__.__module__, pond.__class__.__name__])
sender = Sender(pond)
factory = pb.PBClientFactory()
reactor.connectTCP("localhost", 8800, factory)
deferred = factory.getRootObject()
deferred.addCallback(sender.got_obj)
reactor.run()
|
c4ec28c6 |
if __name__ == '__main__':
|
9c112cd3 |
main()
|