

def _execute_task(arg, cache, dsk=None):
    " Do the actual work of collecting data and executing a function\n\n    Examples\n    --------\n\n    >>> cache = {'x': 1, 'y': 2}\n\n    Compute tasks against a cache\n    >>> _execute_task((add, 'x', 1), cache)  # Compute task in naive manner\n    2\n    >>> _execute_task((add, (inc, 'x'), 1), cache)  # Support nested computation\n    3\n\n    Also grab data from cache\n    >>> _execute_task('x', cache)\n    1\n\n    Support nested lists\n    >>> list(_execute_task(['x', 'y'], cache))\n    [1, 2]\n\n    >>> list(map(list, _execute_task([['x', 'y'], ['y', 'x']], cache)))\n    [[1, 2], [2, 1]]\n\n    >>> _execute_task('foo', cache)  # Passes through on non-keys\n    'foo'\n    "
    if isinstance(arg, list):
        return [_execute_task(a, cache) for a in arg]
    elif istask(arg):
        (func, args) = (arg[0], arg[1:])
        args2 = [_execute_task(a, cache) for a in args]
        return func(*args2)
    elif (not ishashable(arg)):
        return arg
    elif (arg in cache):
        return cache[arg]
    else:
        return arg

dataset/ETHPy150Open dask/dask/dask/async.py _execute_task/original