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

MongoClient.is_mongos should not return an answer if not connected

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.2
    • Affects Version/s: 3.0.3
    • Component/s: None
    • Labels:
      None

      Sometimes I connect a local mongos to our production environment to be able to debug something with live data. This is potentially risky if I forget this process and run our test suite later when I fixed the bug, which is why I have the following code in the module level of our test suite:

      tests/_init_.py
      c = MongoClient("mongodb://localhost:27017")
      if c.is_mongos:
          raise Exception("Connected to a local Mongos instance, need a mongod")
      

      As of upgrading to pymongo 3, this will return False before a connection is established, making this check worthless for the purpose above. For now, I've added c.server_info() before the c.is_mongos check, but I really think it should raise an exception or ensure a connection before returning an answer. Have not checked the other is_* properties as I don't use them, but maybe the problem exists there as well.

            Assignee:
            anna.herlihy@mongodb.com Anna Herlihy (Inactive)
            Reporter:
            daniel@blogg.se daniel@blogg.se
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: