Execute cleanup operation when the decorated function completed.

def _enable_cleanup(func):
    """
    Execute cleanup operation when the decorated function completed.
    """

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        self = args[0]
        result = func(*args, **kwargs)
        self.cleanup(self)
        return result

    return wrapper