def parallel_map(function, *args, **kwargs):
    """Wrapper around IPython's map_sync() that defaults to map().

    This might use IPython's parallel map_sync(), or the standard map()
    function if IPython cannot be used.

    If the 'ask' keyword argument is true, the user will be prompted to start
    IPython engines, but the function will still default to map() if the user
    cancels.
    If the 'ipython' keyword argument is True, the function will return an
    additional boolean indicating whether this was computed through IPython
    (True) or with the default map() function (False).
    """
    say_ipython = kwargs.pop('ipython', False)
    ask = kwargs.pop('ask', False)
    if kwargs:
        raise TypeError("map() got unexpected keyword arguments")

    try:
        import IPython.parallel
    except __HOLE__:
        result, ipython = map(function, *args), False
    else:
        from engine_manager import EngineManager
        c = EngineManager.ensure_controller(connect_only=not ask)
        if c is not None and not c.ids:
            EngineManager.start_engines(
                    prompt="A module is performing a parallelizable "
                    "operation, however no IPython engines are running. Do "
                    "you want to start some?")

        if c is None or not c.ids:
            result, ipython = map(function, *args), False
        else:
            ldview = c.load_balanced_view()
            result, ipython = ldview.map_sync(function, *args), True

    if say_ipython:
        return result, ipython
    else:
        return result
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/parallelflow/api.py/parallel_map