def get_host_view(client):
    # First step: query cluster to fetch one engine id per host
    all_engines = client[:]

    @interactive
    def hostname():
        import socket
        return socket.gethostname()

    hostnames = all_engines.apply(hostname).get_dict()
    one_engine_per_host = dict((hostname, engine_id)
                               for engine_id, hostname
                               in hostnames.items())
    return client[one_engine_per_host.values()]
Return an IPython parallel direct view with one engine per host.
dataset/ETHPy150Open pydata/pyrallel/pyrallel/common.py/get_host_view