'Class to monitor a MongoDB server on a background thread.
Pass an initial ServerDescription, a Topology, a Pool, and
TopologySettings.
The Topology is weakly referenced. The Pool must be exclusive to this
Monitor.'

def __init__(self, server_description, topology, pool, topology_settings):

    self._server_description = server_description
    self._pool = pool
    self._settings = topology_settings
    self._avg_round_trip_time = MovingAverage()
    self._listeners = self._settings._pool_options.event_listeners
    pub = (self._listeners is not None)
    self._publish = (pub and self._listeners.enabled_for_server_heartbeat)
    def target():
        monitor = self_ref()
        if (monitor is None):
            return False
        Monitor._run(monitor)
        return True
    executor = periodic_executor.PeriodicExecutor(interval=self._settings.heartbeat_frequency, min_interval=common.MIN_HEARTBEAT_INTERVAL, target=target, name='pymongo_server_monitor_thread')
    self._executor = executor
    self_ref = weakref.ref(self, executor.close)
    self._topology = weakref.proxy(topology, executor.close)
