human
Complete this python program:
def capture_exceptions(async_result):
assistant
#Here is the Python program you requested.

    """Return a new decorated function that propagates the exceptions of the
    wrapped function to an async_result.
    :param async_result: An async result implementing :class:`IAsyncResult`
    """
    def capture(function):
        @functools.wraps(function)
        def captured_function(*args, **kwargs):
            try:
                return function(*args, **kwargs)
            except Exception as exc:
                async_result.set_exception(exc)
        return captured_function
    return capture