def _process_periodic_tasks(self):
        """Process any pending kill cursors requests and
        maintain connection pool parameters."""
        address_to_cursor_ids = defaultdict(list)

        # Other threads or the GC may append to the queue concurrently.
        while True:
            try:
                address, cursor_ids = self.__kill_cursors_queue.pop()
            except IndexError:
                break

            address_to_cursor_ids[address].extend(cursor_ids)

        # Don't re-open topology if it's closed and there's no pending cursors.
        if address_to_cursor_ids:
            topology = self._get_topology()
            for address, cursor_ids in address_to_cursor_ids.items():
                try:
                    self._kill_cursors(
                        cursor_ids, address, topology, session=None)
                except Exception:
                    helpers._handle_exception()
        try:
            self._topology.update_pool()
        except Exception:
            helpers._handle_exception()
Process any pending kill cursors requests and
        maintain connection pool parameters.
stackoverflow/venv/lib/python3.6/site-packages/pymongo/mongo_client.py