[Twisted-Python] Newbie Q: The first example in Fettig's book

glyph at divmod.com glyph at divmod.com
Sat Jun 3 19:51:23 MDT 2006



On Sun, 4 Jun 2006 09:32:32 +0800, Mike Meng <meng.yan at gmail.com> wrote:
>Hi all,
>    I'm a new Python programmer and just picked up Abe Fettig's "Twisted"
>book. I tried out the first example, which use reactor.run() to drive
>printTime and stopReactor callback functions to print time, and found some
>strange things.
>
>   I wrote the code in a .py file and run it, it's fine. However, when I
>tried to write the code in interactive mode and run it from IDLE shell
>window, all the four printTime were called at once. Why?

Presumably it took you 5 seconds to type all that code interactively, but each callLater is basing the time it wants to run off of the time that it was when you completed each line :).

Either learn to type really, really fast, or put all the callLater calls into a function which you then call interactively.




More information about the Twisted-Python mailing list