RE: [PyOpenGL-Users] Have exceptions terminate glutMainLoop
Brought to you by:
mcfletch
From: Mike C. F. <mcf...@ho...> - 2001-10-06 08:15:56
|
I'm not in agreement regarding the "right way" here. For instance, if you force an exit on an uncaught exception, then any callback raising an exception can cause data loss for the user (a spurious/unimportant exception is raised, rather than being able to use some other menu item (or whatever) to attempt to save their data, the user is booted right out of the program (likely not even seeing the error if they've launched the program directly instead of from a shell)). Fail on any exception is nice for scripting/testing environments, but kicking out of the whole application in larger projects seems too heavy to me. Would redirecting stderr to a log file work? I haven't tried it lately, but I think it should be able to catch the exception output. Anyway, it's late, I'm going to sleep. Enjoy yourselves, Mike -----Original Message----- From: pyo...@li... [mailto:pyo...@li...]On Behalf Of Tarn Weisner Burton Sent: October 5, 2001 19:29 To: PyOpenGL Mailing List Subject: RE: [PyOpenGL-Users] Have exceptions terminate glutMainLoop | Would it be possible to have exceptions raised during | glutMainLoop processing | (ie. in the callbacks) actually terminate the loop? I find that | if there is a | problem, the exception ends up scrolling way off the screen when | the matrix | stack gets confused. I then have to quickly terminate my program | before the | initial exception disappears - which happens often when I'm working in | fullscreen mode. glutMainLoop never returns so it's not possible to pass an exception through the loop. Right now all exceptions are caught before reentering the loop. I did this mostly to make sys.exit work as this was broken in PyGLUT. Although after a bit more thought I think the right way to do this is to exit the script completely on an exception. But for right now if you want to halt the loop this is what you will have to do: ---------------- import traceback def on_display(): try: # draw except: traceback.print_exc() sys.exit(1) glutDisplayFunc(on_display) glutMainLoop() print "This print never gets executed" ---------------- Tarn _______________________________________________ PyOpenGL Homepage http://pyopengl.sourceforge.net _______________________________________________ PyOpenGL-Users mailing list PyO...@li... https://lists.sourceforge.net/lists/listinfo/pyopengl-users |