pool – Pool module for use with a MongoDB client.

class pymongo.pool.PoolOptions

Read only connection pool options for a 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 (Optional[int])

  • connect_timeout (Optional[float])

  • socket_timeout (Optional[float])

  • wait_queue_timeout (Optional[int])

  • ssl_context (Optional[SSLContext])

  • tls_allow_invalid_hostnames (bool)

  • event_listeners (Optional[_EventListeners])

  • appname (Optional[str])

  • driver (Optional[DriverInfo])

  • compression_settings (Optional[CompressionSettings])

  • max_connecting (int)

  • pause_enabled (bool)

  • server_api (Optional[ServerApi])

  • load_balanced (Optional[bool])

  • credentials (Optional[MongoCredential])

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 before being removed and replaced. 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. Cannot be 0.

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 that the pool will maintain 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 if the pool has no free sockets.