per the official PyMongo's documentions for maxIdleTimeMS
maxIdleTimeMS (optional): The maximum number of milliseconds that a connection can remain
idle in the pool before being removed and replaced. Defaults to None (no limit).
The docs says "removed and replaced". My question is regarding the "replaced" part. Will the new connection be created again only when needed or it would be created immediately after closing the existing unused connection.
The maxIdleTimeMS
limits how long a connection can remain idle before being closed.
There are other settings to control how many connection are allowed to be in the pool, he minimum number of connections, and how many connections can be in the opening state simultaneously.
When a connection is close due to idle time out, if the number of connections in the pool is below the minimum, a new one will be opened. If too many are already being opened at that moment, one will be opened later.