Module Expr Str ImportFrom alias ImportFrom alias ImportFrom alias alias alias Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore TupleLoad Str Str Str Str Str FunctionDef arguments args NameParam defaults body Expr Str If CompareIs NameLoad NameLoad body Return NameLoad If UnaryOpNot Call NameLoad NameLoad NameLoad body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad If CompareEq Call NameLoad NameLoad Num body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad For NameStore NameLoad body If UnaryOpNot Call NameLoad NameLoad NameLoad body Raise Call NameLoad BinOpMod Str TupleLoad NameLoad Return NameLoad decorator_list ClassDef bases NameLoad body Expr Str Assign NameStore TupleLoad Str Str Str FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body If BoolOpAnd CompareEq NameLoad NameLoad CompareIsNot NameLoad NameLoad body Raise Call NameLoad Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad AttributeLoad NameLoad attr attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str If CompareIn AttributeLoad NameLoad attr TupleLoad NameLoad ListLoad Dict body Return Dict Str AttributeLoad NameLoad attr Return Dict Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam defaults body Expr Str Return IfExp AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr ListLoad Dict decorator_list NameLoad FunctionDef arguments args NameParam defaults body Return BinOpMod Str TupleLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body If Call NameLoad NameLoad NameLoad body Return BoolOpAnd CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr CompareEq AttributeLoad NameLoad attr AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Return UnaryOpNot CompareEq NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Dict Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad NameLoad Index AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad SubscriptLoad NameLoad Index Str decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Return Str decorator_list FunctionDef arguments args NameParam NameParam defaults body If Call NameLoad NameLoad NameLoad body Return CompareEq AttributeLoad NameLoad attr NameLoad Return NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad If NameLoad body Return NameLoad orelse Return Call NameLoad AttributeLoad NameLoad attr NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad AttributeLoad NameLoad attr NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad AttributeLoad NameLoad attr NameLoad If NameLoad body Return NameLoad orelse Return Call NameLoad NameLoad decorator_list decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam NameParam defaults NameLoad body Expr Call AttributeLoad Call NameLoad NameLoad NameLoad attr NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Return Call NameLoad BoolOpOr AttributeLoad NameLoad attr ListLoad Dict NameLoad decorator_list decorator_list Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad NameLoad FunctionDef arguments args NameParam NameParam defaults body If CompareEq NameLoad NameLoad body If CompareNotIn NameLoad TupleLoad NameLoad ListLoad Dict body Raise Call NameLoad Str Return Call NameLoad Return Call SubscriptLoad NameLoad Index NameLoad NameLoad decorator_list Assign NameStore TupleLoad Str Str Str Str Str ClassDef bases NameLoad body Expr Str Assign NameStore Call NameLoad Assign NameStore Call NameLoad Assign NameStore Call NameLoad Assign NameStore Call NameLoad Assign NameStore Call NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return Call AttributeLoad NameLoad attr NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareLt NameLoad Num body Return If CompareIs AttributeLoad NameLoad attr NameLoad body Assign AttributeStore NameLoad attr NameLoad orelse Assign AttributeStore NameLoad attr BinOpAdd BinOpMult Num AttributeLoad NameLoad attr BinOpMult Num NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Return AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr NameLoad decorator_list decorator_list
N/A N/A Utilities for choosing which member of a replica set to read from. collections Mapping pymongo.errors ConfigurationError pymongo.server_selectors member_with_tags_server_selector secondary_with_tags_server_selector writable_server_selector N/A _PRIMARY 0 N/A _PRIMARY_PREFERRED 1 N/A _SECONDARY 2 N/A _SECONDARY_PREFERRED 3 N/A _NEAREST 4 N/A _MONGOS_MODES N/A primary primaryPreferred secondary secondaryPreferred nearest _validate_tag_sets N/A N/A tag_sets N/A N/A N/A Validate tag sets for a MongoReplicaSetClient.
     N/A N/A tag_sets None N/A N/A tag_sets N/A N/A N/A isinstance tag_sets list N/A N/A N/A TypeError N/A Tag sets %r invalid, must be a list N/A tag_sets N/A N/A N/A len tag_sets 0 N/A N/A N/A ValueError N/A Tag sets %r invalid, must be None or contain at least one set of tags N/A tag_sets N/A tags tag_sets N/A N/A N/A N/A isinstance tags Mapping N/A N/A N/A TypeError N/A Tag set %r invalid, must be an instance of dict, bson.son.SON or other type that inherits from collection.Mapping N/A tags N/A tag_sets N/A _ServerMode N/A object N/A N/A Base class for all read preferences.
     N/A __slots__ N/A __mongos_mode __mode __tag_sets __init__ N/A N/A self mode tag_sets N/A None N/A N/A N/A N/A mode _PRIMARY N/A tag_sets None N/A N/A N/A ConfigurationError Read preference primary cannot be combined with tags N/A N/A self __mongos_mode N/A _MONGOS_MODES N/A mode N/A N/A self __mode mode N/A N/A self __tag_sets N/A _validate_tag_sets tag_sets N/A name N/A N/A self N/A N/A N/A The name of this read preference.
         N/A N/A N/A self __class__ __name__ N/A property document N/A N/A self N/A N/A N/A Read preference as a document.
         N/A N/A N/A self __tag_sets N/A None N/A N/A N/A N/A N/A mode N/A self __mongos_mode N/A N/A mode tags N/A self __mongos_mode N/A self __tag_sets N/A property mode N/A N/A self N/A N/A N/A The mode of this read preference instance.
         N/A N/A self __mode N/A property tag_sets N/A N/A self N/A N/A N/A Set ``tag_sets`` to a list of dictionaries like [{'dc': 'ny'}] to
        read only from members whose ``dc`` tag has the value ``"ny"``.
        To specify a priority-order for tag sets, provide a list of
        tag sets: ``[{'dc': 'ny'}, {'dc': 'la'}, {}]``. A final, empty tag
        set, ``{}``, means "read from any member that matches the mode,
        ignoring tags." MongoReplicaSetClient tries each set of tags in turn
        until it finds a set of tags with at least one matching member.

           .. seealso:: `Data-Center Awareness
               <http://www.mongodb.org/display/DOCS/Data+Center+Awareness>`_
         N/A N/A N/A self __tag_sets N/A list N/A self __tag_sets N/A N/A N/A property __repr__ N/A N/A self N/A N/A N/A N/A %s(tag_sets=%r) N/A N/A self name N/A self __tag_sets N/A __eq__ N/A N/A self other N/A N/A N/A N/A isinstance other _ServerMode N/A N/A N/A N/A N/A self mode N/A other mode N/A N/A self tag_sets N/A other tag_sets N/A NotImplemented N/A __ne__ N/A N/A self other N/A N/A N/A N/A N/A self other N/A __getstate__ N/A N/A self N/A N/A N/A Return value of object for pickling.

        Needed explicitly because __slots__() defined.
         N/A N/A mode tag_sets N/A self __mode N/A self __tag_sets N/A __setstate__ N/A N/A self value N/A N/A N/A Restore from pickling. N/A N/A self __mode N/A value N/A mode N/A N/A self __mongos_mode N/A _MONGOS_MODES N/A N/A self __mode N/A N/A self __tag_sets N/A _validate_tag_sets N/A value N/A tag_sets N/A N/A Primary N/A _ServerMode N/A N/A Primary read preference.

    * When directly connected to one mongod queries are allowed if the server
      is standalone or a replica set primary.
    * When connected to a mongos queries are sent to the primary of a shard.
    * When connected to a replica set queries are sent to the primary of
      the replica set.
     __init__ N/A N/A self N/A N/A N/A N/A N/A N/A super Primary self __init__ _PRIMARY N/A __call__ N/A N/A self server_descriptions N/A N/A N/A Return matching ServerDescriptions from a list. N/A N/A writable_server_selector server_descriptions N/A __repr__ N/A N/A self N/A N/A N/A Primary() N/A __eq__ N/A N/A self other N/A N/A N/A N/A isinstance other _ServerMode N/A N/A N/A N/A other mode _PRIMARY N/A NotImplemented N/A N/A PrimaryPreferred N/A _ServerMode N/A N/A PrimaryPreferred read preference.

    * When directly connected to one mongod queries are allowed to standalone
      servers, to a replica set primary, or to replica set secondaries.
    * When connected to a mongos queries are sent to the primary of a shard if
      available, otherwise a shard secondary.
    * When connected to a replica set queries are sent to the primary if
      available, otherwise a secondary.

    :Parameters:
      - `tag_sets`: The :attr:`~tag_sets` to use if the primary is not
        available.
     __init__ N/A N/A self tag_sets N/A None N/A N/A N/A N/A N/A super PrimaryPreferred self __init__ _PRIMARY_PREFERRED tag_sets N/A __call__ N/A N/A self server_descriptions N/A N/A N/A Return matching ServerDescriptions from a list. N/A writable_servers N/A writable_server_selector server_descriptions N/A writable_servers N/A N/A writable_servers N/A N/A N/A secondary_with_tags_server_selector N/A self tag_sets server_descriptions N/A N/A Secondary N/A _ServerMode N/A N/A Secondary read preference.

    * When directly connected to one mongod queries are allowed to standalone
      servers, to a replica set primary, or to replica set secondaries.
    * When connected to a mongos queries are distributed among shard
      secondaries. An error is raised if no secondaries are available.
    * When connected to a replica set queries are distributed among
      secondaries. An error is raised if no secondaries are available.

    :Parameters:
      - `tag_sets`: The :attr:`~tag_sets` to use with this read_preference
     __init__ N/A N/A self tag_sets N/A None N/A N/A N/A N/A N/A super Secondary self __init__ _SECONDARY tag_sets N/A __call__ N/A N/A self server_descriptions N/A N/A N/A Return matching ServerDescriptions from a list. N/A N/A secondary_with_tags_server_selector N/A self tag_sets server_descriptions N/A N/A SecondaryPreferred N/A _ServerMode N/A N/A SecondaryPreferred read preference.

    * When directly connected to one mongod queries are allowed to standalone
      servers, to a replica set primary, or to replica set secondaries.
    * When connected to a mongos queries are distributed among shard
      secondaries, or the shard primary if no secondary is available.
    * When connected to a replica set queries are distributed among
      secondaries, or the primary if no secondary is available.

    :Parameters:
      - `tag_sets`: The :attr:`~tag_sets` to use with this read_preference
     __init__ N/A N/A self tag_sets N/A None N/A N/A N/A N/A N/A super SecondaryPreferred self __init__ _SECONDARY_PREFERRED tag_sets N/A __call__ N/A N/A self server_descriptions N/A N/A N/A Return matching ServerDescriptions from a list. N/A secondaries N/A secondary_with_tags_server_selector N/A self tag_sets server_descriptions N/A secondaries N/A N/A secondaries N/A N/A N/A writable_server_selector server_descriptions N/A N/A Nearest N/A _ServerMode N/A N/A Nearest read preference.

    * When directly connected to one mongod queries are allowed to standalone
      servers, to a replica set primary, or to replica set secondaries.
    * When connected to a mongos queries are distributed among all members of
      a shard.
    * When connected to a replica set queries are distributed among all
      members.

    :Parameters:
      - `tag_sets`: The :attr:`~tag_sets` to use with this read_preference
     __init__ N/A N/A self tag_sets N/A None N/A N/A N/A N/A N/A super Nearest self __init__ _NEAREST tag_sets N/A __call__ N/A N/A self server_descriptions N/A N/A N/A Return matching ServerDescriptions from a list. N/A N/A member_with_tags_server_selector N/A N/A self tag_sets N/A N/A server_descriptions N/A N/A N/A _ALL_READ_PREFERENCES N/A Primary PrimaryPreferred Secondary SecondaryPreferred Nearest make_read_preference N/A N/A mode tag_sets N/A N/A N/A N/A mode _PRIMARY N/A N/A N/A tag_sets N/A None N/A N/A N/A N/A N/A ConfigurationError Read preference primary cannot be combined with tags N/A N/A Primary N/A N/A N/A _ALL_READ_PREFERENCES N/A mode tag_sets N/A N/A _MODES N/A PRIMARY PRIMARY_PREFERRED SECONDARY SECONDARY_PREFERRED NEAREST ReadPreference N/A object N/A N/A An enum that defines the read preference modes supported by PyMongo.

    See :doc:`/examples/high_availability` for code examples.

    A read preference is used in three cases:

    :class:`~pymongo.mongo_client.MongoClient` connected to a single mongod:

    - ``PRIMARY``: Queries are allowed if the server is standalone or a replica
      set primary.
    - All other modes allow queries to standalone servers, to a replica set
      primary, or to replica set secondaries.

    :class:`~pymongo.mongo_client.MongoClient` initialized with the
    ``replicaSet`` option:

    - ``PRIMARY``: Read from the primary. This is the default, and provides the
      strongest consistency. If no primary is available, raise
      :class:`~pymongo.errors.AutoReconnect`.

    - ``PRIMARY_PREFERRED``: Read from the primary if available, or if there is
      none, read from a secondary.

    - ``SECONDARY``: Read from a secondary. If no secondary is available,
      raise :class:`~pymongo.errors.AutoReconnect`.

    - ``SECONDARY_PREFERRED``: Read from a secondary if available, otherwise
      from the primary.

    - ``NEAREST``: Read from any member.

    :class:`~pymongo.mongo_client.MongoClient` connected to a mongos, with a
    sharded cluster of replica sets:

    - ``PRIMARY``: Read from the primary of the shard, or raise
      :class:`~pymongo.errors.OperationFailure` if there is none.
      This is the default.

    - ``PRIMARY_PREFERRED``: Read from the primary of the shard, or if there is
      none, read from a secondary of the shard.

    - ``SECONDARY``: Read from a secondary of the shard, or raise
      :class:`~pymongo.errors.OperationFailure` if there is none.

    - ``SECONDARY_PREFERRED``: Read from a secondary of the shard if available,
      otherwise from the shard primary.

    - ``NEAREST``: Read from any shard member.
     N/A PRIMARY N/A Primary N/A PRIMARY_PREFERRED N/A PrimaryPreferred N/A SECONDARY N/A Secondary N/A SECONDARY_PREFERRED N/A SecondaryPreferred N/A NEAREST N/A Nearest N/A read_pref_mode_from_name N/A N/A name N/A N/A N/A Get the read preference mode from mongos/uri name.
     N/A N/A N/A _MONGOS_MODES index name N/A MovingAverage N/A object N/A N/A Tracks an exponentially-weighted moving average. __init__ N/A N/A self N/A N/A N/A N/A self average None N/A add_sample N/A N/A self sample N/A N/A N/A N/A sample 0 N/A N/A N/A N/A N/A self average None N/A N/A N/A self average sample N/A N/A N/A self average N/A N/A 0.8 N/A self average N/A 0.2 sample N/A get N/A N/A self N/A N/A N/A Get the calculated average, or None if no samples yet. N/A N/A self average N/A reset N/A N/A self N/A N/A N/A N/A self average None N/A N/A