PYTHON-1591 - Deprecate Collection.parallel_scan

This commit is contained in:
Bernie Hackett 2018-06-21 12:03:42 -07:00
parent 709b28467f
commit 388339e187
4 changed files with 17 additions and 2 deletions

View File

@ -65,6 +65,8 @@ Deprecations:
:meth:`~pymongo.mongo_client.MongoClient.list_database_names` instead.
- Deprecated :meth:`~pymongo.database.Database.collection_names`. Use
:meth:`~pymongo.database.Database.list_collection_names` instead.
- Deprecated :meth:`~pymongo.collection.Collection.parallel_scan`. MongoDB 4.2
will remove the parallelCollectionScan command.
Unavoidable breaking changes:

View File

@ -1450,7 +1450,7 @@ class Collection(common.BaseObject):
return RawBatchCursor(self, *args, **kwargs)
def parallel_scan(self, num_cursors, session=None, **kwargs):
"""Scan this entire collection in parallel.
"""**DEPRECATED**: Scan this entire collection in parallel.
Returns a list of up to ``num_cursors`` cursors that can be iterated
concurrently. As long as the collection is not modified during
@ -1492,6 +1492,9 @@ class Collection(common.BaseObject):
.. note:: Requires server version **>= 2.5.5**.
.. versionchanged:: 3.7
Deprecated.
.. versionchanged:: 3.6
Added ``session`` parameter.
@ -1504,6 +1507,9 @@ class Collection(common.BaseObject):
Removed support for arbitrary keyword arguments, since
the parallelCollectionScan command has no optional arguments.
"""
warnings.warn("parallel_scan is deprecated. MongoDB 4.2 will remove "
"the parallelCollectionScan command.",
DeprecationWarning, stacklevel=2)
cmd = SON([('parallelCollectionScan', self.__name),
('numCursors', num_cursors)])
cmd.update(kwargs)

View File

@ -1662,6 +1662,8 @@ class TestCollection(IntegrationTest):
self.assertTrue(cursor.alive)
@client_context.require_no_mongos
@client_context.require_version_max(4, 1, 0)
@ignore_deprecations
def test_parallel_scan(self):
db = self.db
db.drop_collection("test")
@ -1688,7 +1690,9 @@ class TestCollection(IntegrationTest):
@client_context.require_no_mongos
@client_context.require_version_min(3, 3, 10)
@client_context.require_version_max(4, 1, 0)
@client_context.require_test_commands
@ignore_deprecations
def test_parallel_scan_max_time_ms(self):
self.client.admin.command("configureFailPoint",
"maxTimeAlwaysTimeOut",

View File

@ -320,6 +320,8 @@ class TestSession(IntegrationTest):
(coll.aggregate, [[]], {}))
@client_context.require_no_mongos
@client_context.require_version_max(4, 1, 0)
@ignore_deprecations
def test_parallel_collection_scan(self):
listener = self.listener
client = self.client
@ -771,7 +773,8 @@ class TestCausalConsistency(unittest.TestCase):
self._test_reads(
lambda coll, session: coll.inline_map_reduce(
'function() {}', 'function() {}', session=session))
if not client_context.is_mongos:
if (not client_context.is_mongos and
not client_context.version.at_least(4, 1, 0)):
def scan(coll, session):
cursors = coll.parallel_scan(1, session=session)
for cur in cursors: