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

Function make_read_preference

pymongo/read_preferences.py:524–535  ·  view source on GitHub ↗
(
    mode: int, tag_sets: Optional[_TagSets], max_staleness: int = -1
)

Source from the content-addressed store, hash-verified

522
523
524def make_read_preference(
525 mode: int, tag_sets: Optional[_TagSets], max_staleness: int = -1
526) -> _ServerMode:
527 if mode == _PRIMARY:
528 if tag_sets not in (None, [{}]):
529 raise ConfigurationError("Read preference primary cannot be combined with tags")
530 if max_staleness != -1:
531 raise ConfigurationError(
532 "Read preference primary cannot be combined with maxStalenessSeconds"
533 )
534 return Primary()
535 return _ALL_READ_PREFERENCES[mode](tag_sets, max_staleness) # type: ignore
536
537
538_MODES = (

Callers 5

testFunction · 0.90
testFunction · 0.90
testFunction · 0.90
testFunction · 0.90
_parse_read_preferenceFunction · 0.90

Calls 2

ConfigurationErrorClass · 0.90
PrimaryClass · 0.85

Tested by 4

testFunction · 0.72
testFunction · 0.72
testFunction · 0.72
testFunction · 0.72