def excepthook(self, exception_type, exception_value, traceback_object): gui_message = fileexcepthook(exception_type, exception_value, traceback_object) # we do not want to flood the user with message boxes when the error happens repeatedly on each timer event if not self.errorDialogOpened: self.errorDialogOpened = True errorBox(gui_message) self.errorDialogOpened = False