ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 4.20.0
    • Affects Version/s: 4.18.2
    • Component/s: None
    • None
    • None
    • Python Drivers
    • Completed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?
    • None
    • None
    • None
    • None
    • None
    • None

      The maxPoolSize docs say: "Can be either 0 or None, in which case there is no limit on the number of concurrent connections", and the pool treats both as unlimited (if not self.max_pool_size: self.max_pool_size = float("inf")).

      However, _parse_pool_options in pymongo/client_options.py only exempts None from the minPoolSize check:

      if max_pool_size is not None and min_pool_size > max_pool_size:
          raise ValueError("minPoolSize must be smaller or equal to maxPoolSize")
      

      so 0 is treated as a real limit.

      Reproduction

      from pymongo import MongoClient
      MongoClient("mongodb://localhost", connect=False, maxPoolSize=None, minPoolSize=5)  # OK
      MongoClient("mongodb://localhost", connect=False, maxPoolSize=0, minPoolSize=5)
      # ValueError: minPoolSize must be smaller or equal to maxPoolSize
      

      Expected
      Both calls are accepted, since 0 and None both mean "no limit".

      Proposed fix
      Skip the check when maxPoolSize is 0 or None:

      if max_pool_size and min_pool_size > max_pool_size:
      

      Environment: PyMongo 4.18.2, Python 3.12, Linux.

       

            Assignee:
            Alex Clark
            Reporter:
            M. Chetan N/A (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: