[Twisted-Python] question on pb-client

Naoya Maruyama naoya at matsulab.is.titech.ac.jp
Wed Sep 22 00:10:38 EDT 2004


Hello,

I'm new to Twisted and want to use the Perspective Broker. I read the
howto pages of the web site, but I coundn't find answer of my question.

I'm testing the echo server/clinet (pbsimpleserver.py and
pbsimpleclient.py). I can successfully run them, but if I change the
client to the following, the result seems strange.

---
from twisted.spread import pb
from twisted.internet import reactor
from twisted.python import util

factory = pb.PBClientFactory()
reactor.connectTCP("localhost", 8789, factory)

def test():
    d = factory.getRootObject()
    d.addCallback(lambda object: object.callRemote("echo", "hello network"))
    d.addCallback(lambda echo: 'server echoed: '+echo)
    d.addErrback(lambda reason: 'error: '+str(reason.value))
    d.addCallback(util.println)
    d.addCallback(lambda _: reactor.stop())
    reactor.run()
    return

# calls test twice
test()
test()
---

If I execute this client code, the client doesn't finish running. And
the server prints out "echoing: hello network" only once. So, it seems
that the client failed to get the root object, or to call the remote
method. What's the problem? I can't get the root object multiple times?

Thanks,

naoya





More information about the Twisted-Python mailing list