diff --git a/common/lib/xmodule/xmodule/mongo_utils.py b/common/lib/xmodule/xmodule/mongo_utils.py index e2f08982f7..5daeff034e 100644 --- a/common/lib/xmodule/xmodule/mongo_utils.py +++ b/common/lib/xmodule/xmodule/mongo_utils.py @@ -30,19 +30,6 @@ def connect_to_mongodb( handles AutoReconnect errors by retrying read operations, since these exceptions typically indicate a temporary step-down condition for MongoDB. """ - # The MongoReplicaSetClient class is deprecated in Mongo 3.x, in favor of using - # the MongoClient class for all connections. Update/simplify this code when using - # PyMongo 3.x. - if kwargs.get('replicaSet'): - # Enable reading from secondary nodes in the MongoDB replicaset by using the - # MongoReplicaSetClient class. - # The 'replicaSet' parameter in kwargs is required for secondary reads. - # The read_preference should be set to a proper value, like SECONDARY_PREFERRED. - mongo_client_class = pymongo.MongoReplicaSetClient - else: - # No 'replicaSet' in kwargs - so no secondary reads. - mongo_client_class = pymongo.MongoClient - # If the MongoDB server uses a separate authentication database that should be specified here auth_source = kwargs.get('authsource', '') or None @@ -65,7 +52,7 @@ def connect_to_mongodb( kwargs['read_preference'] = read_preference mongo_conn = pymongo.database.Database( - mongo_client_class( + pymongo.MongoClient( host=host, port=port, tz_aware=tz_aware,