def connected(client):
    with warnings.catch_warnings():
        # Ignore warning that "ismaster" is always routed to primary even
        # if client's read preference isn't PRIMARY.
        warnings.simplefilter("ignore", UserWarning)
        client.admin.command('ismaster')  # Force connection.

    return client
Convenience to wait for a newly-constructed client to connect.
dataset/ETHPy150Open mongodb/mongo-python-driver/test/utils.py/connected