def NotifyErrorListeners(): from mu_repo.backwards_stringio import StringIO import traceback cstr = StringIO() traceback.print_exc(file=cstr) error = cstr.getvalue() for listener in on_errors_listeners: listener(error) Print(error)
def PrintError(msg=''): from mu_repo.backwards_stringio import StringIO s = StringIO() s.write('\n===================================== ERROR =====================================\n') if msg: s.write(msg) s.write('\n\n') import traceback;traceback.print_exc(file=s) s.write('\n=================================================================================\n\n') #On a single write, the GIL should be locked, so, the output should still appear to be synched #for a single error. sys.stdout.write(s.getvalue())