MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / _get_seedlist

Method _get_seedlist

pymongo/synchronous/monitor.py:409–434  ·  view source on GitHub ↗

Poll SRV records for a seedlist. Returns a list of ServerDescriptions.

(self)

Source from the content-addressed store, hash-verified

407 self.close()
408
409 def _get_seedlist(self) -> Optional[list[tuple[str, Any]]]:
410 """Poll SRV records for a seedlist.
411
412 Returns a list of ServerDescriptions.
413 """
414 try:
415 resolver = _SrvResolver(
416 self._fqdn,
417 self._settings.pool_options.connect_timeout,
418 self._settings.srv_service_name,
419 )
420 seedlist, ttl = resolver.get_hosts_and_min_ttl()
421 if len(seedlist) == 0:
422 # As per the spec: this should be treated as a failure.
423 raise Exception
424 except Exception as exc:
425 # As per the spec, upon encountering an error:
426 # - An error must not be raised
427 # - SRV records must be rescanned every heartbeatFrequencyMS
428 # - Topology must be left unchanged
429 self.request_check()
430 _debug_log(_SDAM_LOGGER, message="SRV monitor check failed", failure=repr(exc))
431 return None
432 else:
433 self._executor.update_interval(max(ttl, common.MIN_SRV_RESCAN_INTERVAL))
434 return seedlist
435
436
437class _RttMonitor(MonitorBase):

Callers 1

_runMethod · 0.95

Calls 5

_SrvResolverClass · 0.90
_debug_logFunction · 0.90
get_hosts_and_min_ttlMethod · 0.45
request_checkMethod · 0.45
update_intervalMethod · 0.45

Tested by

no test coverage detected