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

Add more information to connection errors and timeouts

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.6
    • Affects Version/s: None
    • Component/s: None
    • None

      For issues like: https://www.mongodb.com/community/forums/t/connection-timed-out-errors-while-creating-index/240271

      It would be helpful to add more information to network timeout errors. For example we could add the timeout being used (eg connectTimeout/socketTimeout/csot timeout) and perhaps the time elapsed before the exception was raised.

      For example the current behavior is:

      >>> c = MongoClient(socketTimeoutMS=1)
      >>> c.t.t.find_one({})
      Traceback (most recent call last):
      ...
        File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 402, in _raise_connection_failure
          raise NetworkTimeout(msg) from error
      pymongo.errors.NetworkTimeout: localhost:27017: timed out
      

      We could raise something like this:

      >>> c = MongoClient(socketTimeoutMS=1)
      >>> c.t.t.find_one({})
      Traceback (most recent call last):
      ...
        File "/Users/shane/git/mongo-python-driver/pymongo/pool.py", line 402, in _raise_connection_failure
          raise NetworkTimeout(msg) from error
      pymongo.errors.NetworkTimeout: localhost:27017: timed out (waited 1ms, configured timeout was 1ms)
      

            Assignee:
            noah.stapp@mongodb.com Noah Stapp
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: