def errorhook(exc_info=None): """This is the main entry point Call in an exception context. Thread safe. def my_thread(): try: do_work() except Exception: errorhook() """ global _error_lock, _errorhook_enabled if not _errorhook_enabled: return if exc_info is None: exc_info = sys.exc_info() if exc_info[0] is None: # called outside of an exception context, just ignore print_e("no active exception!") return # In case something goes wrong during error handling print it first print_exc(exc_info) if not _error_lock.acquire(False): # Make sure only one of these is active at a time return # write error and logs to disk dump_dir = os.path.join(quodlibet.get_user_dir(), "dumps") dump_to_disk(dump_dir, exc_info) sentry = get_sentry() # For crashes the stack trace is not enough to differentiating different # crash sources. We need to give our own grouping key (fingerprint) based # on the stack trace provided by faulthandler. fingerprint = None if isinstance(exc_info[1], FaultHandlerCrash): fingerprint = ["{{ default }}", exc_info[1].get_grouping_key()] try: sentry_error = sentry.capture(exc_info, fingerprint=fingerprint) except SentryError: sentry_error = None def called_in_main_thread(): try: run_error_dialogs(exc_info, sentry_error) finally: _error_lock.release() if is_main_thread(): called_in_main_thread() else: GLib.idle_add(called_in_main_thread)
def errorhook(exc_info=None): """This is the main entry point Call in an exception context. Thread safe. def my_thread(): try: do_work() except Exception: errorhook() """ global _error_lock, _errorhook_enabled if not _errorhook_enabled: return if exc_info is None: exc_info = sys.exc_info() if exc_info[0] is None: # called outside of an exception context, just ignore print_e("no active exception!") return # In case something goes wrong during error handling print it first print_exc(exc_info) if not _error_lock.acquire(False): # Make sure only one of these is active at a time return # write error and logs to disk dump_dir = os.path.join(quodlibet.get_user_dir(), "dumps") dump_to_disk(dump_dir, exc_info) sentry = get_sentry() # For crashes the stack trace is not enough to differentiating different # crash sources. We need to give our own grouping key (fingerprint) based # on the stack trace provided by faulthandler. fingerprint = None if isinstance(exc_info[1], FaultHandlerCrash): fingerprint = ["{{ default }}", exc_info[1].get_grouping_key()] try: sentry_error = sentry.capture(exc_info, fingerprint=fingerprint) except SentryError: sentry_error = None def called_in_main_thread(): try: run_error_dialogs(exc_info, sentry_error) finally: _error_lock.release() if is_main_thread(): called_in_main_thread() else: GLib.idle_add(called_in_main_thread)
def func(i): self.assertTrue(util.is_main_thread()) return i + 1
def func(i): self.assertTrue(util.is_main_thread()) return i + 1