No framelistener traceback

bigjhnny

25-03-2006 16:21:05

Does anyone else get a traceback when an exception occurs at your framelistener class?

No matter how I change this, anything that throws an exception in my listener class hangs the whole app....

How do you all cope with this?

dermont

26-03-2006 08:08:13

I've encountered similar problems using pyCegui and exceptions within events. I resolved this by wrapping the problem code in try/except.

Clay's made an update to Exception handling a few months back in CVS, don't know if this would resolve your particular case.

Post an example of the code causing the problem.

bigjhnny

26-03-2006 18:27:18

Here. Notice I'm using twisted and running the Ogre render loop within a twisted "LoopingCall". I'll try this later without twisted if we suspect that twisted would cause this.

The magic is at the frameStarted method. On my machine, it hangs without traceback on the "ShouldProvideTraceback" line, even with try, except, pass....

EDIT: note I tried later again with "try, except" it did actually provide the traceback.

Thanks in advance!

# main.py
from pyogre import ogre
import SampleFramework as sf
from sys import stdout
from twisted.internet import reactor, task

class ApplicationFramework(object):
def __init__(self):
self.root = ogre.Root( ogre.getPluginPath() )
configFile = ogre.ConfigFile()
configFile.loadFromFile( "../configs/resources.cfg" )
for section, key, path in configFile.values:
ogre.ResourceGroupManager.getSingleton().addResourceLocation( path, key, section )

renList = self.root.getAvailableRenderers()
for r in renList:
if r.name.startswith( "OpenGL" ):
# if r.name.startswith('Direct'):
self.root.renderSystem = r

stdout.write("OpenGL renderer not found!")

self.root.initialise(False)
self.renderWindow = self.root.createRenderWindow( "PyOgreWindow", 800, 600, False )
self.sceneManager = self.root.getSceneManager(ogre.ST_GENERIC)
self.camera = self.sceneManager.createCamera( "RootCam" )
self.camera.nearClipDistance = 5
self.camera.position = (180, 300, 335)
self.camera.lookAt((0,0,0))

ogre.TextureManager.getSingleton().defaultNumMipmaps = 5
ogre.ResourceGroupManager.getSingleton().initialiseAllResourceGroups()
self.viewport = self.renderWindow.addViewport( self.camera )
self.viewport.backgroundColour = (0, 0, 0)
self._createFrameListener()

def __del__(self):
"Clear variables, this is needed to ensure the correct order of deletion"
del self.camera
del self.sceneManager
del self.frameListener
del self.system
del self.guiRenderer
del self.root
del self.renderWindow

def render(self):
self.root.renderOneFrame()

def _createFrameListener(self):
self.frameListener = ListenerFramework(self.renderWindow, self.camera, self)
self.frameListener.showDebugOverlay(True)
self.root.addFrameListener(self.frameListener)

class ListenerFramework(sf.FrameListener):
def __init__(self, renderWindow, camera, client):
self.client = client
sf.FrameListener.__init__(self, renderWindow, camera)

def frameStarted(self, evt):
print "i'm in frameStarted"
ShouldProvideTraceback
return sf.FrameListener.frameStarted(self, evt)

app = ApplicationFramework()
l = task.LoopingCall(app.render)
l.start(0)
reactor.run()

bigjhnny

26-03-2006 18:38:01

Without using the twisted loop, using my own while loop, this code does produce a traceback.... :shock:


class ListenerFramework(sf.FrameListener):
def __init__(self, renderWindow, camera, client):
self.client = client
sf.FrameListener.__init__(self, renderWindow, camera)

def frameStarted(self, evt):
print "i'm in frameStarted"
ShouldProvideTraceback
return sf.FrameListener.frameStarted(self, evt)

app = ApplicationFramework()
while True:
app.render()


Traceback (most recent call last):
...
File line 48,
in render
self.root.renderOneFrame()
File "C:\Python24\Lib\site-packages\pyogre\ogre.py", line 13540, in renderOneF
rame
return _ogre.Root_renderOneFrame(*args)
NameError: Swig director python method error: Error detected when calling Combin
edListener.frameStarted.
global name 'ShouldProvideTraceback' is not defined



Wonder if there is any other way I can get a traceback on exception besides using the try, except with twisted running...

bigjhnny

27-03-2006 20:53:23

Hi, I have another note:

why wouldn't wrapping the "renderOneFrame" call with a try except be sufficient to provide tracebacks in frame listener (frameStarted for example)? I almost have to wrap all methods in frame listeners with try except, which defeats the purpose....

Additionally, is the bug you referred to in pyogre that results in no traceback fixed? Or is this problem still unique to me using twisted? As my app gets bigger, it almost becomes impossible to find what happened during a hang without printing out a message in every step of the code....

dermont

29-03-2006 21:46:50

Sorry I don't know the answer. The problem still exists in cegui event callbacks, so it's not unique to you. The only way I've found to avoid the problems of hanging the application is wrapping each method in try/ except. As you point out doing so is a pain since its almost requires printing out a message in every step of the code.

bigjhnny

29-03-2006 23:37:59

Sorry I don't know the answer. The problem still exists in cegui event callbacks, so it's not unique to you. The only way I've found to avoid the problems of hanging the application is wrapping each method in try/ except. As you point out doing so is a pain since its almost requires printing out a message in every step of the code.

Fair enough. Definately appreciate the response though. Do keep us updated if the bug is fixed.

Fosk

30-03-2006 12:05:26

I don't know if it is relevent but when I was working on the wxPyOgre class, I noticed something that might be related. The original wxdemo file was a subclass of wx.app and exhibited the same problem you described. I changed it to a wx.pyapp subclass and the exceptions got written on screen without problem. Maybe having a look at the differences between the two classes might give an idea of what is causing the problem...

just my 2 yen worth....

Fosk