pool – Pool module for use with a MongoDB client.

class pymongo.pool.PoolOptions

Read only connection pool options for an AsyncMongoClient/MongoClient.

Should not be instantiated directly by application developers. Access a client’s pool options via pool_options instead:

pool_opts = client.options.pool_options
pool_opts.max_pool_size
pool_opts.min_pool_size
Parameters:
  • max_pool_size (int)

  • min_pool_size (int)

  • max_idle_time_seconds (int | None)

  • connect_timeout (float | None)

  • socket_timeout (float | None)

  • wait_queue_timeout (int | None)

  • ssl_context (SSLContext | None)

  • tls_allow_invalid_hostnames (bool)

  • event_listeners (_EventListeners | None)

  • appname (str | None)

  • driver (DriverInfo | None)

  • compression_settings (CompressionSettings | None)

  • max_connecting (int)

  • pause_enabled (bool)

  • server_api (ServerApi | None)

  • load_balanced (bool | None)

  • credentials (MongoCredential | None)

  • is_sync (bool | None)

property appname: str | None

The application name, for sending with hello in server handshake.

property connect_timeout: float | None

How long a connection can take to be opened before timing out.

property driver: DriverInfo | None

Driver name and version, for sending with hello in handshake.

property load_balanced: bool | None

True if this Pool is configured in load balanced mode.

property max_connecting: int

The maximum number of concurrent connection creation attempts per pool. Defaults to 2.

property max_idle_time_seconds: int | None

The maximum number of seconds that a connection can remain idle in the pool.

The connection is removed and replaced after this time. Defaults to None (no limit).

property max_pool_size: float

The maximum allowable number of concurrent connections to each connected server.

Requests to a server will block if there are maxPoolSize outstanding connections to the requested server. Defaults to 100. A value of 0 or None means no limit.

When a server’s pool has reached max_pool_size, operations for that server block waiting for a socket to be returned to the pool. If waitQueueTimeoutMS is set, a blocked operation will raise ConnectionFailure after a timeout. By default waitQueueTimeoutMS is not set.

property metadata: dict[str, Any]

A dict of metadata about the application, driver, os, and platform.

property min_pool_size: int

The minimum required number of concurrent connections to each connected server.

The pool will maintain at least this many connections to each connected server. Default is 0.

property non_default_options: dict[str, Any]

The non-default options this pool was created with.

Added for CMAP’s PoolCreatedEvent.

property server_api: ServerApi | None

A pymongo.server_api.ServerApi or None.

property socket_timeout: float | None

How long a send or receive on a socket can take before timing out.

property tls_allow_invalid_hostnames: bool

If True skip ssl.match_hostname.

property wait_queue_timeout: int | None

How long a thread will wait for a socket from the pool.

This only applies if the pool has no free sockets.