@@ -1165,10 +1165,10 @@ def close(self):
1165
1165
session_ids = self ._topology .pop_all_sessions ()
1166
1166
if session_ids :
1167
1167
self ._end_sessions (session_ids )
1168
- # Stop the periodic task thread and then run _process_periodic_tasks
1169
- # to send pending killCursor requests before closing the topology.
1168
+ # Stop the periodic task thread and then send pending killCursor
1169
+ # requests before closing the topology.
1170
1170
self ._kill_cursors_executor .close ()
1171
- self ._process_periodic_tasks ()
1171
+ self ._process_kill_cursors ()
1172
1172
self ._topology .close ()
1173
1173
if self ._encrypter :
1174
1174
# TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
@@ -1717,10 +1717,8 @@ def _kill_cursors(self, cursor_ids, address, topology, session):
1717
1717
duration , reply , 'killCursors' , request_id ,
1718
1718
tuple (address ))
1719
1719
1720
- # This method is run periodically by a background thread.
1721
- def _process_periodic_tasks (self ):
1722
- """Process any pending kill cursors requests and
1723
- maintain connection pool parameters."""
1720
+ def _process_kill_cursors (self ):
1721
+ """Process any pending kill cursors requests."""
1724
1722
address_to_cursor_ids = defaultdict (list )
1725
1723
1726
1724
# Other threads or the GC may append to the queue concurrently.
@@ -1741,6 +1739,12 @@ def _process_periodic_tasks(self):
1741
1739
cursor_ids , address , topology , session = None )
1742
1740
except Exception :
1743
1741
helpers ._handle_exception ()
1742
+
1743
+ # This method is run periodically by a background thread.
1744
+ def _process_periodic_tasks (self ):
1745
+ """Process any pending kill cursors requests and
1746
+ maintain connection pool parameters."""
1747
+ self ._process_kill_cursors ()
1744
1748
try :
1745
1749
self ._topology .update_pool ()
1746
1750
except Exception :
0 commit comments