|
53 | 53 | from pymongo.change_stream import ClusterChangeStream
|
54 | 54 | from pymongo.client_options import ClientOptions
|
55 | 55 | from pymongo.command_cursor import CommandCursor
|
56 |
| -from pymongo.cursor_manager import CursorManager |
57 | 56 | from pymongo.errors import (AutoReconnect,
|
58 | 57 | BulkWriteError,
|
59 | 58 | ConfigurationError,
|
@@ -704,7 +703,6 @@ def __init__(
|
704 | 703 |
|
705 | 704 | self.__default_database_name = dbase
|
706 | 705 | self.__lock = threading.Lock()
|
707 |
| - self.__cursor_manager = None |
708 | 706 | self.__kill_cursors_queue = []
|
709 | 707 |
|
710 | 708 | self._event_listeners = options.pool_options.event_listeners
|
@@ -1209,35 +1207,6 @@ def close(self):
|
1209 | 1207 | # TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
|
1210 | 1208 | self._encrypter.close()
|
1211 | 1209 |
|
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 |
| - |
1241 | 1210 | def _get_topology(self):
|
1242 | 1211 | """Get the internal :class:`~pymongo.topology.Topology` object.
|
1243 | 1212 |
|
@@ -1584,8 +1553,7 @@ def close_cursor(self, cursor_id, address=None):
|
1584 | 1553 | """DEPRECATED - Send a kill cursors message soon with the given id.
|
1585 | 1554 |
|
1586 | 1555 | 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)``. |
1589 | 1557 |
|
1590 | 1558 | This method may be called from a :class:`~pymongo.cursor.Cursor`
|
1591 | 1559 | destructor during garbage collection, so it isn't safe to take a
|
@@ -1620,30 +1588,22 @@ def _close_cursor(self, cursor_id, address):
|
1620 | 1588 | cursor manager. If there is none, the cursor is closed asynchronously
|
1621 | 1589 | on a background thread.
|
1622 | 1590 | """
|
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])) |
1627 | 1592 |
|
1628 | 1593 | def _close_cursor_now(self, cursor_id, address=None, session=None):
|
1629 | 1594 | """Send a kill cursors message with the given id.
|
1630 | 1595 |
|
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. |
1634 | 1597 | """
|
1635 | 1598 | if not isinstance(cursor_id, integer_types):
|
1636 | 1599 | raise TypeError("cursor_id must be an instance of (int, long)")
|
1637 | 1600 |
|
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])) |
1647 | 1607 |
|
1648 | 1608 | def kill_cursors(self, cursor_ids, address=None):
|
1649 | 1609 | """DEPRECATED - Send a kill cursors message soon with the given ids.
|
|
0 commit comments