Decorator to catch and print the exceptions that happen within async tasks.
    Note: this should be applied to methods of VSphereCheck only!

def trace_method(method):
    """
    Decorator to catch and print the exceptions that happen within async tasks.
    Note: this should be applied to methods of VSphereCheck only!
    """

    def wrapper(*args, **kwargs):
        try:
            method(*args, **kwargs)
        except Exception:
            args[0].print_exception("A worker thread crashed:\n" + traceback.format_exc())

    return wrapper