def read_from_which_host(
        client,
        pref,
        tag_sets=None,
):
    """Read from a client with the given Read Preference.

    Return the 'host:port' which was read from.

    :Parameters:
      - `client`: A MongoClient
      - `mode`: A ReadPreference
      - `tag_sets`: List of dicts of tags for data-center-aware reads
    """
    db = client.pymongo_test

    if isinstance(tag_sets, dict):
        tag_sets = [tag_sets]
    if tag_sets:
        tags = tag_sets or pref.tag_sets
        pref = pref.__class__(tags)

    db.read_preference = pref

    cursor = db.test.find()
    try:
        try:
            next(cursor)
        except __HOLE__:
            # No documents in collection, that's fine
            pass

        return cursor.address
    except AutoReconnect:
        return None
dataset/ETHPy150Open mongodb/mongo-python-driver/test/utils.py/read_from_which_host