In my application I have a loop that in each turn creates an instance of a class which performs some operations. In this class I have a signal timer that when invoked is supposed to exit the current turn in the loop gracefully and allow the next operation to continue without any interruption.
In it’s current state it raises an exception that is supposed to be caught by a try-except-block. However I have a “loadFinished” signal (that I don’t know the id for) that is invoked after the exception is thrown and causes a runtime exception on the function definition that I can’t catch.
Is there a way to do a class level return like one would do to end a function if something is wrong? Or maybe some kind of sys.exit() that only works on the class?
I hope I made myself clear. 🙂 Thank you for your help.
Christopher,
maybe using Timer and Event classes is more appropriate for you. You could check for the event to be set inside you loop an then exit the current iteration:
I think what you are trying to do is not really a good design. I see no way to “throw” an exception into a different function. I assume by signal you mean asynchronous function call. This of course could also set the event mentioned above.