MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / __init__

Method __init__

pymongo/asynchronous/monitor.py:129–167  ·  view source on GitHub ↗

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.

(
        self,
        server_description: ServerDescription,
        topology: Topology,
        pool: Pool,
        topology_settings: TopologySettings,
    )

Source from the content-addressed store, hash-verified

127
128class Monitor(MonitorBase):
129 def __init__(
130 self,
131 server_description: ServerDescription,
132 topology: Topology,
133 pool: Pool,
134 topology_settings: TopologySettings,
135 ):
136 """Class to monitor a MongoDB server on a background thread.
137
138 Pass an initial ServerDescription, a Topology, a Pool, and
139 TopologySettings.
140
141 The Topology is weakly referenced. The Pool must be exclusive to this
142 Monitor.
143 """
144 super().__init__(
145 topology,
146 "pymongo_server_monitor_task",
147 topology_settings.heartbeat_frequency,
148 common.MIN_HEARTBEAT_INTERVAL,
149 )
150 self._server_description = server_description
151 self._pool = pool
152 self._settings = topology_settings
153 self._listeners = self._settings._pool_options._event_listeners
154 self._publish = self._listeners is not None and self._listeners.enabled_for_server_heartbeat
155 self._cancel_context: Optional[_CancellationContext] = None
156 self._conn_id: Optional[int] = None
157 self._rtt_monitor = _RttMonitor(
158 topology,
159 topology_settings,
160 topology._create_pool_for_monitor(server_description.address),
161 )
162 if topology_settings.server_monitoring_mode == "stream":
163 self._stream = True
164 elif topology_settings.server_monitoring_mode == "poll":
165 self._stream = False
166 else:
167 self._stream = not _is_faas()
168
169 def cancel_check(self) -> None:
170 """Cancel any concurrent hello check.

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 3

_is_faasFunction · 0.90
_RttMonitorClass · 0.70

Tested by

no test coverage detected