[Twisted-Python] Twisted and python-ogre

Werner Thie wthie at thiengineering.ch
Thu Feb 14 13:12:18 EST 2008

Hi Thomas

Looks like the twisted event loop should be in control and Ogre should 
be called like

     hb = task.LoopingCall(ogre.heartBeat) #system pump

with ogre.heartbeat operating along the line of

Ogre::Root::getSingletonPtr()->renderOneFrame(); //C++ code

I don't know if this particular C++ call is exposed in PyOgre, but we 
have Ogre running in a networked multiplayer wxWidgets app written in 
C++ with exactly that setup, although the limit is - only one Ogre 
window per app when using this approach.

I would be really interested in how you solved your problem!

In the meantime
HTH, Werner

Thomas Boucher wrote:
> Hello,
> I am currently part of a MMORPG project in python, using Twisted
> and python-ogre. I found some posts talking about the cohabitation 
> between the two. However I couldn't find a definitive answer. What I am 
> seeking for is more a general method than technical details.
> What I would like to do is to put properly Twisted and python-ogre
> together. To do that I have already tried the following ways :
>  - First run python-ogre in the main loop. At a time, this loop launches
> the twisted reactor in another thread with Thread(target =
> sthg_which_runs_reactor.run).
> The problem I am experiencing is described here [1]. The sendLine method
> is executed immediately, but the data is received by the other side only
> 20/30 seconds after.
>  - So I tried not to run Twisted in another thread, by using the way
> described here [2]. Twisted is given the main loop and the
> rendering is done frame by frame with the coiterate. It works sometimes,
> the renderOneFrame in the coiterration is not really working.
> But it seems more logical to run ptyhon-ogre in the main loop and
> twisted on the side (in another thread for example, as soon as the 
> client has decided to connect to the server). Have you any ideas how I 
> could do this properly (with threads, without threads, with the 
> coiterrate ...)?
> If Twisted was originally made for MMORPGs, why the reactor wants so 
> much to be in the main loop and to manage itself the other threads (with 
> callInThread for example)?
> Cheers
> [1] http://archives.free.net.ph/message/20080102.113837.4c4513eb.en.html
> [2] 
> http://www.ogre3d.org/phpBB2addons/viewtopic.php?p=35187&sid=ce193664e1d3d7c4af509e6f4e2718c6 

More information about the Twisted-Python mailing list