Example #1
0
def is_delivered(a_promise):
    """
    True if `a_promise` is a promise and has been delivered
    """

    return is_proxy_delivered(a_promise) if is_proxy(a_promise) \
        else a_promise.is_delivered()
Example #2
0
def is_promise(obj):
    """
    True if `obj` is a promise (either a proxy or a container)
    """

    return (is_proxy(obj) or \
                (hasattr(obj, "is_delivered") and
                 hasattr(obj, "deliver")))
Example #3
0
def deliver(on_promise):
    """
    Attempts to deliver on a promise, and returns the resulting
    value. If the delivery of work causes an exception, it will be
    raised here.

    Parameters
    ----------
    on_promise : `Proxy` or `Container` promise
      the promise to deliver on

    Returns
    -------
    value
      the promised work if it could be successfully computed
    """

    return deliver_proxy(on_promise) if is_proxy(on_promise) \
        else on_promise.deliver()