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

Error message when raising a SeverSelectionTimeoutError should hint at a faulty server_selector when it is configured

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      PYTHON-1577 introduced the ability for a user to provide a server_selector function that augments the server selection process in an arbitrary, user-defined way. Currently, the error message we display with a SeverSelectionTimeoutError does not mention that server selection could have failed due to an improperly defined selector function. We should make this error message 'smarter' to hint to the user that the server_selector could be a source of possible error when selection times out and a custom selector is being used by the client.

      Here is what a SeverSelectionTimeoutError with a faulty server_selector currently looks like:

      In[2]: from pymongo import MongoClient
      In[3]: def selector(selectors):
        ...:     return []
      In[4]: mc = MongoClient(replicaSet='replSet', server_selector=selector)
      In[5]: mc.db.coll.insert_one({'a': 1})
      Traceback (most recent call last):
       ...
      pymongo.errors.ServerSelectionTimeoutError: No primary available for writes
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            prashant.mital Prashant Mital (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: