@@ -1165,10 +1165,10 @@ def close(self):
11651165 session_ids = self ._topology .pop_all_sessions ()
11661166 if session_ids :
11671167 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.
11701170 self ._kill_cursors_executor .close ()
1171- self ._process_periodic_tasks ()
1171+ self ._process_kill_cursors ()
11721172 self ._topology .close ()
11731173 if self ._encrypter :
11741174 # TODO: PYTHON-1921 Encrypted MongoClients cannot be re-opened.
@@ -1717,10 +1717,8 @@ def _kill_cursors(self, cursor_ids, address, topology, session):
17171717 duration , reply , 'killCursors' , request_id ,
17181718 tuple (address ))
17191719
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."""
17241722 address_to_cursor_ids = defaultdict (list )
17251723
17261724 # Other threads or the GC may append to the queue concurrently.
@@ -1741,6 +1739,12 @@ def _process_periodic_tasks(self):
17411739 cursor_ids , address , topology , session = None )
17421740 except Exception :
17431741 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 ()
17441748 try :
17451749 self ._topology .update_pool ()
17461750 except Exception :
0 commit comments