You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
:class:`~pymongo.asynchronous.cursor.AsyncCursor` corresponding to this query.
1778
1778
1779
+
Cursors are closed automatically when they are exhausted (the last batch of data is retrieved from the database).
1780
+
If a cursor is not exhausted, it will be closed automatically upon garbage collection, which leaves resources open but unused for a potentially long period of time.
1781
+
To avoid this, best practice is to call :meth:`AsyncCursor.close` when the cursor is no longer needed,
1782
+
or use the cursor in a with statement::
1783
+
1784
+
async with collection.find() as cursor:
1785
+
async for doc in cursor:
1786
+
print(doc)
1787
+
1779
1788
The :meth:`find` method obeys the :attr:`read_preference` of
Cursors are closed automatically when they are exhausted (the last batch of data is retrieved from the database).
2516
+
If a cursor is not exhausted, it will be closed automatically upon garbage collection, which leaves resources open but unused for a potentially long period of time.
2517
+
To avoid this, best practice is to call :meth:`AsyncCursor.close` when the cursor is no longer needed,
2518
+
or use the cursor in a with statement::
2519
+
2520
+
async with await collection.list_indexes() as cursor:
"""Return a cursor over search indexes for the current collection.
2622
2640
2641
+
Cursors are closed automatically when they are exhausted (the last batch of data is retrieved from the database).
2642
+
If a cursor is not exhausted, it will be closed automatically upon garbage collection, which leaves resources open but unused for a potentially long period of time.
2643
+
To avoid this, best practice is to call :meth:`AsyncCursor.close` when the cursor is no longer needed,
2644
+
or use the cursor in a with statement::
2645
+
2646
+
async with await collection.list_search_indexes() as cursor:
2647
+
async for index in cursor:
2648
+
print(index)
2649
+
2623
2650
:param name: If given, the name of the index to search
2624
2651
for. Only indexes with matching index names will be returned.
2625
2652
If not given, all search indexes for the current collection
@@ -2922,6 +2949,15 @@ async def aggregate(
2922
2949
.. note:: The :attr:`~pymongo.asynchronous.collection.AsyncCollection.write_concern` of
2923
2950
this collection is automatically applied to this operation.
2924
2951
2952
+
Cursors are closed automatically when they are exhausted (the last batch of data is retrieved from the database).
2953
+
If a cursor is not exhausted, it will be closed automatically upon garbage collection, which leaves resources open but unused for a potentially long period of time.
2954
+
To avoid this, best practice is to call :meth:`AsyncCursor.close` when the cursor is no longer needed,
2955
+
or use the cursor in a with statement::
2956
+
2957
+
async with await collection.aggregate() as cursor:
2958
+
async for operation in cursor:
2959
+
print(operation)
2960
+
2925
2961
:param pipeline: a list of aggregation pipeline stages
0 commit comments