[Twisted-Python] question on pb-client
Christopher Armstrong
radeex at gmail.com
Wed Sep 22 00:34:49 EDT 2004
On Tue, 21 Sep 2004 23:10:38 -0500, Naoya Maruyama
<naoya at matsulab.is.titech.ac.jp> wrote:
> 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
Just call reactor.run() once, at the very end of this script, and only
call reactor.stop() once, as a callback to the second test() call. So,
in summary, make test() *not* addCallback a reactor.stop, make it
_not_ call reactor.run, and change your second test() call to
test().addCallback(lambda _: reactor.stop()) and then put
reactor.run() after that.
>
> # calls test twice
> test()
> test()
--
Twisted | Christopher Armstrong: International Man of Twistery
Radix | Release Manager, Twisted Project
---------+ http://radix.twistedmatrix.com
More information about the Twisted-Python
mailing list