
On Saturday 09 June 2007, Simon Pickles wrote:
Now, I am only a beginner at twisted, but it looks to me if I called run(), I won't have a chance to call iterate() cos twisted will have gone into its mainloop and stolen all control!
You should make your code run inside of (under control of) the reactor. I think what you're looking for is the callLater method: reactor.callLater(delay_in_seconds, function, arg1, arg2, ...) In the function, do a little bit of work, then schedule another callLater and let the function return. That way, the reactor can handle the network traffic before going back to processing for example AI. If it's not easy to divide the AI code in fast-executing chunks, you could consider running it on a separate thread, but then you have to be careful to properly guard all concurrent access to shared data. Another option is to run in the AI in a different process, if there is not too much communication between the network part and the AI. Bye, Maarten