(f)
return wrapper
A decorator that catches the TaskState.UserCancelException exception
    and clears the exception's traceback to remove local references.

    Parameters
    ----------
    f : callable

    Returns
    -------
    wrapped : callable
A decorator that catches the TaskState.UserCancelException exception
    and clears the exception's traceback to remove local references.
A decorator that catches the TaskState . UserCancelException exception and clears the exception s traceback to remove local references .
def clear_stack_on_cancel(f):
    """
    A decorator that catches the TaskState.UserCancelException exception
    and clears the exception's traceback to remove local references.

    Parameters
    ----------
    f : callable

    Returns
    -------
    wrapped : callable
    """
    def wrapper(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except TaskState.UserCancelException as e:
            # TODO: Is this enough to allow immediate gc of the stack?
            # How does it chain across cython code?
            # Maybe just return None.
            e = e.with_traceback(None)
            e.__context__ = None
            e.__cause__ = None
            raise e
        except BaseException as e:
            traceback.clear_frames(e.__traceback__)
            raise

    return wrapper
def clear_stack_on_cancel ( f ) : def wrapper ( * args , * * kwargs ) : try : return f ( * args , * * kwargs ) except TaskState . UserCancelException as e : # TODO: Is this enough to allow immediate gc of the stack? # How does it chain across cython code? # Maybe just return None. e = e . with_traceback ( None ) e . __context__ = None e . __cause__ = None raise e except BaseException as e : traceback . clear_frames ( e . __traceback__ ) raise return wrapper