def _delete_non_persistent_datasets_if_allowed():
    """Deletes all non-persistent datasets if and only if we are the only
    client currently connected to the database.
    """
    try:
        num_connections = len(
            list(
                _client.admin.aggregate(
                    [
                        {"$currentOp": {"allUsers": True}},
                        {"$project": {"appName": True, "command": True}},
                        {
                            "$match": {
                                "appName": foc.DATABASE_APPNAME,
                                "$or": [
                                    {"command.ismaster": 1},
                                    {"command.hello": 1},
                                ],
                            }
                        },
                    ]
                )
            )
        )
    except:
        logger.debug(
            "Skipping automatic non-persistent dataset cleanup. This action "
            "requires read access of the 'admin' database"
        )
        return

    try:
        if num_connections <= 1:
            fod.delete_non_persistent_datasets()
    except:
        logger.exception("Skipping automatic non-persistent dataset cleanup")
Deletes all non-persistent datasets if and only if we are the only
    client currently connected to the database.
    
fiftyone/core/odm/database.py