Skip to content

Commit 9dec2c9

Browse files
kaldownShaneHarvey
authored andcommitted
PYTHON-1301 Remove support for cursor managers
Remove MongoClient.set_cursor_manager Remove pymongo.cursor_manager.
1 parent 56925fd commit 9dec2c9

File tree

4 files changed

+9
-215
lines changed

4 files changed

+9
-215
lines changed

doc/api/pymongo/cursor_manager.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

pymongo/cursor_manager.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

pymongo/mongo_client.py

Lines changed: 9 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
from pymongo.change_stream import ClusterChangeStream
5454
from pymongo.client_options import ClientOptions
5555
from pymongo.command_cursor import CommandCursor
56-
from pymongo.cursor_manager import CursorManager
5756
from pymongo.errors import (AutoReconnect,
5857
BulkWriteError,
5958
ConfigurationError,
@@ -704,7 +703,6 @@ def __init__(
704703

705704
self.__default_database_name = dbase
706705
self.__lock = threading.Lock()
707-
self.__cursor_manager = None
708706
self.__kill_cursors_queue = []
709707

710708
self._event_listeners = options.pool_options.event_listeners
@@ -1209,35 +1207,6 @@ def close(self):
12091207
# TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
12101208
self._encrypter.close()
12111209

1212-
def set_cursor_manager(self, manager_class):
1213-
"""DEPRECATED - Set this client's cursor manager.
1214-
1215-
Raises :class:`TypeError` if `manager_class` is not a subclass of
1216-
:class:`~pymongo.cursor_manager.CursorManager`. A cursor manager
1217-
handles closing cursors. Different managers can implement different
1218-
policies in terms of when to actually kill a cursor that has
1219-
been closed.
1220-
1221-
:Parameters:
1222-
- `manager_class`: cursor manager to use
1223-
1224-
.. versionchanged:: 3.3
1225-
Deprecated, for real this time.
1226-
1227-
.. versionchanged:: 3.0
1228-
Undeprecated.
1229-
"""
1230-
warnings.warn(
1231-
"set_cursor_manager is Deprecated",
1232-
DeprecationWarning,
1233-
stacklevel=2)
1234-
manager = manager_class(self)
1235-
if not isinstance(manager, CursorManager):
1236-
raise TypeError("manager_class must be a subclass of "
1237-
"CursorManager")
1238-
1239-
self.__cursor_manager = manager
1240-
12411210
def _get_topology(self):
12421211
"""Get the internal :class:`~pymongo.topology.Topology` object.
12431212
@@ -1584,8 +1553,7 @@ def close_cursor(self, cursor_id, address=None):
15841553
"""DEPRECATED - Send a kill cursors message soon with the given id.
15851554
15861555
Raises :class:`TypeError` if `cursor_id` is not an instance of
1587-
``(int, long)``. What closing the cursor actually means
1588-
depends on this client's cursor manager.
1556+
``(int, long)``.
15891557
15901558
This method may be called from a :class:`~pymongo.cursor.Cursor`
15911559
destructor during garbage collection, so it isn't safe to take a
@@ -1620,30 +1588,22 @@ def _close_cursor(self, cursor_id, address):
16201588
cursor manager. If there is none, the cursor is closed asynchronously
16211589
on a background thread.
16221590
"""
1623-
if self.__cursor_manager is not None:
1624-
self.__cursor_manager.close(cursor_id, address)
1625-
else:
1626-
self.__kill_cursors_queue.append((address, [cursor_id]))
1591+
self.__kill_cursors_queue.append((address, [cursor_id]))
16271592

16281593
def _close_cursor_now(self, cursor_id, address=None, session=None):
16291594
"""Send a kill cursors message with the given id.
16301595
1631-
What closing the cursor actually means depends on this client's
1632-
cursor manager. If there is none, the cursor is closed synchronously
1633-
on the current thread.
1596+
The cursor is closed synchronously on the current thread.
16341597
"""
16351598
if not isinstance(cursor_id, integer_types):
16361599
raise TypeError("cursor_id must be an instance of (int, long)")
16371600

1638-
if self.__cursor_manager is not None:
1639-
self.__cursor_manager.close(cursor_id, address)
1640-
else:
1641-
try:
1642-
self._kill_cursors(
1643-
[cursor_id], address, self._get_topology(), session)
1644-
except PyMongoError:
1645-
# Make another attempt to kill the cursor later.
1646-
self.__kill_cursors_queue.append((address, [cursor_id]))
1601+
try:
1602+
self._kill_cursors(
1603+
[cursor_id], address, self._get_topology(), session)
1604+
except PyMongoError:
1605+
# Make another attempt to kill the cursor later.
1606+
self.__kill_cursors_queue.append((address, [cursor_id]))
16471607

16481608
def kill_cursors(self, cursor_ids, address=None):
16491609
"""DEPRECATED - Send a kill cursors message soon with the given ids.

test/test_cursor_manager.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

0 commit comments

Comments
 (0)