def delayed(f):
def wrapped(*args, **kwargs):<EOL><INDENT>key_promise = list([(key, promisify(value)) for key, value in kwargs.items()])<EOL>arg_promises = list([promisify(value) for value in args])<EOL>kwarg_promises = list([promise for key, promise in key_promise])<EOL>promises = arg_promises + kwarg_promises<EOL>for promise in promises:<EOL><INDENT>def echo_error(exc, promise=promise):<EOL><INDENT>print("<STR_LIT>", promise, "<STR_LIT>", exc)<EOL><DEDENT>def echo(value, promise=promise):<EOL><INDENT>print("<STR_LIT>", repr(promise), "<STR_LIT>", value)<EOL><DEDENT><DEDENT>allarguments = aplus.listPromise(*promises)<EOL>def call(_):<EOL><INDENT>kwargs_real = {key: promise.get() for key, promise in key_promise}<EOL>args_real = list([promise.get() for promise in arg_promises])<EOL>return f(*args_real, **kwargs_real)<EOL><DEDENT>def error(exc):<EOL><INDENT>print("<STR_LIT:error>", exc)<EOL>raise exc<EOL><DEDENT>return allarguments.then(call, error)<EOL><DEDENT>return wrapped<EOL>
Decorator to transparantly accept delayed computation.

    Example:

    >>> delayed_sum = ds.sum(ds.E, binby=ds.x, limits=limits,
    >>>                   shape=4, delay=True)
    >>> @vaex.delayed
    >>> def total_sum(sums):
    >>>     return sums.sum()
    >>> sum_of_sums = total_sum(delayed_sum)
    >>> ds.execute()
    >>> sum_of_sums.get()
    See the tutorial for a more complete example https://docs.vaex.io/en/latest/tutorial.html#Parallel-computations