[Twisted-Python] question on pb-client
Naoya Maruyama
naoya at matsulab.is.titech.ac.jp
Wed Sep 22 02:23:33 EDT 2004
So, is there no way to stop the reactor and rerun it?
naoya
Christopher Armstrong wrote:
> 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()
>
>
More information about the Twisted-Python
mailing list