@@ -123,14 +123,28 @@ By default, the driver uses only those members whose ping times are within 15 mi
123123of the nearest member for queries. To distribute reads between members with
124124higher latencies, pass the ``localThresholdMS`` option to the ``MongoClient()`` constructor.
125125
126- The following example specifies a local threshold of 35 milliseconds:
126+ The following example specifies a local threshold of 35 milliseconds. Select the
127+ :guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the corresponding code:
127128
128- .. code-block:: python
129- :emphasize-lines: 3
129+ .. tabs::
130+
131+ .. tab:: Synchronous
132+ :tabid: sync
133+
134+ .. code-block:: python
135+
136+ client = MongoClient(replicaSet='repl0',
137+ readPreference=ReadPreference.SECONDARY_PREFERRED,
138+ localThresholdMS=35)
139+
140+ .. tab:: Asynchronous
141+ :tabid: async
130142
131- client = MongoClient(replicaSet='repl0',
132- readPreference=ReadPreference.SECONDARY_PREFERRED,
133- localThresholdMS=35)
143+ .. code-block:: python
144+
145+ client = AsyncMongoClient(replicaSet='repl0',
146+ readPreference=ReadPreference.SECONDARY_PREFERRED,
147+ localThresholdMS=35)
134148
135149In the preceding example, {+driver-short+} distributes reads between matching members
136150within 35 milliseconds of the closest member's ping time.
@@ -150,12 +164,27 @@ if they fail due to a network or server error.
150164
151165You can explicitly disable retryable reads or retryable writes by setting the ``retryReads`` or
152166``retryWrites`` option to ``False`` in the ``MongoClient()`` constructor. The following
153- example disables retryable reads and writes for a client:
167+ example disables retryable reads and writes for a client. Select the
168+ :guilabel:`Synchronous` or :guilabel:`Asynchronous` tab to see the corresponding code:
154169
155- .. code-block:: python
170+ .. tabs::
171+
172+ .. tab:: Synchronous
173+ :tabid: sync
174+
175+ .. code-block:: python
176+
177+ client = MongoClient("<connection string>",
178+ retryReads=False, retryWrites=False)
179+
180+ .. tab:: Asynchronous
181+ :tabid: async
182+
183+ .. code-block:: python
184+
185+ client = AsyncMongoClient("<connection string>",
186+ retryReads=False, retryWrites=False)
156187
157- client = MongoClient("<connection string>",
158- retryReads=False, retryWrites=False)
159188
160189To learn more about supported retryable read operations, see :manual:`Retryable Reads </core/retryable-reads/>`
161190in the {+mdb-server+} manual. To learn more about supported retryable write
@@ -170,12 +199,27 @@ you perform on the collection.
170199.. include:: /includes/collation-description.rst
171200
172201The following example creates the same collection as the previous example,
173- but with a default collation of ``fr_CA``:
202+ but with a default collation of ``fr_CA``. Select the :guilabel:`Synchronous` or
203+ :guilabel:`Asynchronous` tab to see the corresponding code:
174204
175- .. code-block:: python
176- :emphasize-lines: 4
205+ .. tabs::
206+
207+ .. tab:: Synchronous
208+ :tabid: sync
177209
178- from pymongo.collation import Collation
210+ .. code-block:: python
211+
212+ from pymongo.collation import Collation
213+
214+ database = client["test_database"]
215+ database.create_collection("example_collection", collation=Collation(locale='fr_CA'))
179216
180- database = client["test_database"]
181- database.create_collection("example_collection", collation=Collation(locale='fr_CA'))
217+ .. tab:: Asynchronous
218+ :tabid: async
219+
220+ .. code-block:: python
221+
222+ from pymongo.collation import Collation
223+
224+ database = client["test_database"]
225+ await database.create_collection("example_collection", collation=Collation(locale='fr_CA'))
0 commit comments