Returns a new effect that will delay the execution
    of the given effect and return the specified result right away.

    @param effect: the effect to delay
    @type  effect: callable
    @param result: the value to return right away
    @type  result: Any
    @param delay:  the time to wait before performing
                   the specified effect, in seconds
    @type  delay:  float

    @return: a new effect that will delay the given effect
    @rtype:  callable

def delay(effect, result=None, delay=0.001):
    """
    Returns a new effect that will delay the execution
    of the given effect and return the specified result right away.

    @param effect: the effect to delay
    @type  effect: callable
    @param result: the value to return right away
    @type  result: Any
    @param delay:  the time to wait before performing
                   the specified effect, in seconds
    @type  delay:  float

    @return: a new effect that will delay the given effect
    @rtype:  callable
    """

    def delay(value, context, **params):
        d = defer.Deferred()
        d.addCallback(effect, context, **params)
        time.call_next(d.callback, value)
        return result

    return delay