(self, server_description)
Process a new ServerDescription after an ismaster call completes.
Process a new ServerDescription after an ismaster call completes.
Process a new ServerDescription after an ismaster call completes .
def on_change(self, server_description):
        """Process a new ServerDescription after an ismaster call completes."""
        # We do no I/O holding the lock.
        with self._lock:
            # Any monitored server was definitely in the topology description
            # once. Check if it's still in the description or if some state-
            # change removed it. E.g., we got a host list from the primary
            # that didn't include this server.
            if self._description.has_server(server_description.address):
                td_old = self._description
                if self._publish_server:
                    old_server_description = td_old._server_descriptions[
                        server_description.address]
                    self._events.put((
                        self._listeners.publish_server_description_changed,
                        (old_server_description, server_description,
                         server_description.address, self._topology_id)))

                self._description = updated_topology_description(
                    self._description, server_description)

                self._update_servers()

                if self._publish_tp:
                    self._events.put((
                        self._listeners.publish_topology_description_changed,
                        (td_old, self._description, self._topology_id)))

                # Wake waiters in select_servers().
                self._condition.notify_all()
def on_change ( self , server_description ) : # We do no I/O holding the lock. with self . _lock : # Any monitored server was definitely in the topology description # once. Check if it's still in the description or if some state- # change removed it. E.g., we got a host list from the primary # that didn't include this server. if self . _description . has_server ( server_description . address ) : td_old = self . _description if self . _publish_server : old_server_description = td_old . _server_descriptions [ server_description . address ] self . _events . put ( ( self . _listeners . publish_server_description_changed , ( old_server_description , server_description , server_description . address , self . _topology_id ) ) ) self . _description = updated_topology_description ( self . _description , server_description ) self . _update_servers ( ) if self . _publish_tp : self . _events . put ( ( self . _listeners . publish_topology_description_changed , ( td_old , self . _description , self . _topology_id ) ) ) # Wake waiters in select_servers(). self . _condition . notify_all ( )