[Twisted-Python] question on pb-client
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
participants (4)
-
Christopher Armstrong
-
exarkun@divmod.com
-
Naoya Maruyama
-
Uwe C. Schroeder