Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-927

Document the non-static nature of MongoClient.nodes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial - P5
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.0.1
    • Fix Version/s: 3.0.2
    • Component/s: None
    • Labels:
      None
    • Environment:
      3.0.2-1-dce3f36

      Description

      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?

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: