AsyncMongoClient: timed out any request when using uvloop

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • 4.15.1
    • Affects Version/s: 4.15.0
    • Component/s: async
    • None
    • Python Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Detailed steps to reproduce the problem?

      On PyMongo version 4.15.0 if we use uvloop (the latest version is 0.21.0), we get timeout for any request with asynchronous client.

      A minimal code example:

       

      import pymongo, uvloop
      
      async def mongo_info():
          c = pymongo.AsyncMongoClient('mongodb://localhost:27017')
          info = await c.server_info()
          print(info)
       
      uvloop.run(mongo_info())

       

      This code does not work with PyMongo 4.15.0 and works fine with PyMongo 4.14.1

      Error:

      pymongo.errors.ServerSelectionTimeoutError: localhost:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms), Timeout: 30s, Topology Description: <TopologyDescription id: 68c2e1984d3d91e9826abd09, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27017) server_type: Unknown, rtt: None, error=NetworkTimeout('localhost:27017: timed out (configured timeouts: socketTimeoutMS: 20000.0ms, connectTimeoutMS: 20000.0ms)')>]> 

      Definition of done: what must be done to consider the task complete?

      Fix the described problem. PyMongo >=4.15.0 should work correctly with uvloop.

      The exact Python version used, with patch level:

      3.11.13 (main, Jun  4 2025, 08:57:30) [GCC 13.3.0]

      The exact version of PyMongo used, with patch level:

      4.15.0

      Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.

      docker/mongo:latest

      The operating system and version (e.g. Windows 7, OSX 10.8, ...)

      Ubuntu 24.04 WSL2

       

            Assignee:
            Alex Clark
            Reporter:
            esp N/A
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: