Skip to content

Conversation

blink1073
Copy link
Member

@blink1073 blink1073 commented Aug 26, 2025

Currently testing with this script:

import asyncio
from pymongo import AsyncMongoClient

client = AsyncMongoClient(maxConnecting=100)

async def target():
    return await client.admin.command("ping")

async def main():
    # Warm the pool so there are existing connections.
    tasks = []
    for i in range(10):
        tasks.append(asyncio.create_task(target()))
    await asyncio.wait(tasks)

    tasks = []
    for i in range(200):
        tasks.append(asyncio.create_task(target()))

    await asyncio.wait(tasks)

asyncio.run(main())

blink1073 and others added 15 commits August 19, 2025 11:23
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…b#2507)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Steven Silvester <[email protected]>
conn.conn.get_conn.read(1)
except Exception as _:
# TODO: verify the exception
close_conn = False
Copy link
Member

@ShaneHarvey ShaneHarvey Aug 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 comments:

  1. I believe this logic needs to move to connection checkout. Here in connection check in we already know the connection is useable because we're checking it back in after a successful command.
  2. Instead of a 1ms read can we reuse the existing _perished() + conn_closed() methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

@ShaneHarvey ShaneHarvey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants