@@ -1403,7 +1403,7 @@ def find(self, *args, **kwargs):
1403
1403
def find_raw_batches (self , * args , ** kwargs ):
1404
1404
"""Query the database and retrieve batches of raw BSON.
1405
1405
1406
- Takes the same parameters as :meth:`find` but returns a
1406
+ Similar to the :meth:`find` method but returns a
1407
1407
:class:`~pymongo.cursor.RawBatchCursor`.
1408
1408
1409
1409
This example demonstrates how to work with raw batches, but in practice
@@ -1416,11 +1416,15 @@ def find_raw_batches(self, *args, **kwargs):
1416
1416
>>> for batch in cursor:
1417
1417
... print(bson.decode_all(batch))
1418
1418
1419
- Unlike most PyMongo methods, this method sends no session id to the
1420
- server.
1419
+ .. note:: find_raw_batches does not support sessions.
1421
1420
1422
1421
.. versionadded:: 3.6
1423
1422
"""
1423
+ # OP_MSG with document stream returns is required to support
1424
+ # sessions.
1425
+ if "session" in kwargs :
1426
+ raise ConfigurationError (
1427
+ "find_raw_batches does not support sessions" )
1424
1428
return RawBatchCursor (self , * args , ** kwargs )
1425
1429
1426
1430
def parallel_scan (self , num_cursors , session = None , ** kwargs ):
@@ -2181,7 +2185,7 @@ def aggregate(self, pipeline, session=None, **kwargs):
2181
2185
def aggregate_raw_batches (self , pipeline , ** kwargs ):
2182
2186
"""Perform an aggregation and retrieve batches of raw BSON.
2183
2187
2184
- Takes the same parameters as :meth:`aggregate` but returns a
2188
+ Similar to the :meth:`aggregate` method but returns a
2185
2189
:class:`~pymongo.cursor.RawBatchCursor`.
2186
2190
2187
2191
This example demonstrates how to work with raw batches, but in practice
@@ -2195,11 +2199,15 @@ def aggregate_raw_batches(self, pipeline, **kwargs):
2195
2199
>>> for batch in cursor:
2196
2200
... print(bson.decode_all(batch))
2197
2201
2198
- Unlike most PyMongo methods, this method sends no session id to the
2199
- server.
2202
+ .. note:: aggregate_raw_batches does not support sessions.
2200
2203
2201
2204
.. versionadded:: 3.6
2202
2205
"""
2206
+ # OP_MSG with document stream returns is required to support
2207
+ # sessions.
2208
+ if "session" in kwargs :
2209
+ raise ConfigurationError (
2210
+ "aggregate_raw_batches does not support sessions" )
2203
2211
return self ._aggregate (pipeline , RawBatchCommandCursor , 0 ,
2204
2212
None , False , ** kwargs )
2205
2213
0 commit comments