Re: [PyOpenGL-Users] Have exceptions terminate glutMainLoop
Brought to you by:
mcfletch
|
From: Richard J. <ric...@op...> - 2001-10-06 23:05:28
|
On Sat, 6 Oct 2001 18:18, Mike C. Fletcher wrote:
> 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
Woah there. I'm of the firm belief that if an exception is not handled in
code, it's never going to be a "spurious/unimportant exception". It is, by
definition, an "exception" to the correct running of the code. It means that
something has happened that the programmer did not expect, and is likely to
cause lots of problems. The Python way of handling exceptions that are not
caught is to terminate the program to avoid complications. Consider that the
exception occurred during processing of the user's data. The
"spurious/unimportant exception" is ignored, and the user is given the option
to unknowingly save their corrupted data.
> 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.
I suggest that the C callback handlers exit when they detect an exception
(the alternative is to quit the gluMainLoop, but we can't do that). As a
trade-off, have the exit behaviour dependant on some environment setting:
. gluMainLoop(suppress_exceptions=1)
. gluMainLoopSuppressExceptions
. os.environ['GLU_MAINLOOP_SUPPRESS_EXCEPTIONS'] = 1
Richard
|