Document the non-static nature of MongoClient.nodes

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Trivial - P5
    • 3.0.2
    • Affects Version/s: 3.0, 3.0.1
    • Component/s: None
    • None
    • Environment:
      3.0.2-1-dce3f36
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I'm passing around a MongoClient and sometimes need to know what I'm connected to (previously we used host, port).

      It looks like client.nodes is empty for sometime after Client creation:

      In [32]: for i in xrange(1000):
          c = pymongo.MongoClient('cn14-ib:27119')
          time.sleep(0.00001)
          assert c.nodes, i
         ....:     
      ---------------------------------------------------------------------------
      AssertionError                            Traceback (most recent call last)
      <ipython-input-32-993619bacd76> in <module>()
            2     c = pymongo.MongoClient('cn14-ib:27119')
            3     time.sleep(0.00001)
      ----> 4     assert c.nodes, i
            5 
      
      AssertionError: 12
      

      The docs say:
      http://api.mongodb.org/python/current/api/pymongo/mongo_client.html?highlight=mongoclient#pymongo.mongo_client.MongoClient.nodes

      nodes
      List of all connected servers.
      Nodes are either specified when this instance was created, or discovered through the replica set discovery mechanism.

      In this case nodes is empty, so is neither what was passed into the MongoClient, nor discovered...

      If you put a server_info() in there, then nodes is reliable. Is there a better way to get the original connection string?

            Assignee:
            Bernie Hackett
            Reporter:
            James Blackburn
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: