Skip to content

Commit 4589d75

Browse files
kaldownShaneHarvey
authored andcommitted
PYTHON-1301 Remove support for cursor managers
Remove MongoClient.set_cursor_manager Remove pymongo.cursor_manager.
1 parent 7737679 commit 4589d75

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
@@ -1211,35 +1209,6 @@ def close(self):
12111209
# TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
12121210
self._encrypter.close()
12131211

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

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

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

16501610
def kill_cursors(self, cursor_ids, address=None):
16511611
"""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)