OpenQuizz
Une application de gestion des contenus pédagogiques
Pool Class Reference

Public Member Functions

def __init__ (self, address, options, handshake=True)
 
def update_is_writable (self, is_writable)
 
def reset (self)
 
def close (self)
 
def remove_stale_sockets (self, reference_generation, all_credentials)
 
def connect (self, all_credentials=None)
 
def get_socket (self, all_credentials, checkout=False)
 
def return_socket (self, sock_info)
 
def __del__ (self)
 

Data Fields

 sockets
 
 lock
 
 active_sockets
 
 next_connection_id
 
 closed
 
 is_writable
 
 generation
 
 pid
 
 address
 
 opts
 
 handshake
 
 enabled_for_cmap
 

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  address,
  options,
  handshake = True 
)
:Parameters:
  - `address`: a (hostname, port) tuple
  - `options`: a PoolOptions instance
  - `handshake`: whether to call ismaster for each new SocketInfo

◆ __del__()

def __del__ (   self)

Member Function Documentation

◆ close()

def close (   self)

◆ connect()

def connect (   self,
  all_credentials = None 
)
Connect to Mongo and return a new SocketInfo.

Can raise ConnectionFailure or CertificateError.

Note that the pool does not keep a reference to the socket -- you
must call return_socket() when you're done with it.

◆ get_socket()

def get_socket (   self,
  all_credentials,
  checkout = False 
)
Get a socket from the pool. Use with a "with" statement.

Returns a :class:`SocketInfo` object wrapping a connected
:class:`socket.socket`.

This method should always be used in a with-statement::

    with pool.get_socket(credentials, checkout) as socket_info:
socket_info.send_message(msg)
data = socket_info.receive_message(op_code, request_id)

The socket is logged in or out as needed to match ``all_credentials``
using the correct authentication mechanism for the server's wire
protocol version.

Can raise ConnectionFailure or OperationFailure.

:Parameters:
  - `all_credentials`: dict, maps auth source to MongoCredential.
  - `checkout` (optional): keep socket checked out.

◆ remove_stale_sockets()

def remove_stale_sockets (   self,
  reference_generation,
  all_credentials 
)
Removes stale sockets then adds new ones if pool is too small and
has not been reset. The `reference_generation` argument specifies the
`generation` at the point in time this operation was requested on the
pool.

◆ reset()

def reset (   self)

◆ return_socket()

def return_socket (   self,
  sock_info 
)
Return the socket to the pool, or if it's closed discard it.

:Parameters:
  - `sock_info`: The socket to check into the pool.

◆ update_is_writable()

def update_is_writable (   self,
  is_writable 
)
Updates the is_writable attribute on all sockets currently in the
Pool.

Field Documentation

◆ active_sockets

active_sockets

◆ address

address

◆ closed

closed

◆ enabled_for_cmap

enabled_for_cmap

◆ generation

generation

◆ handshake

handshake

◆ is_writable

is_writable

◆ lock

lock

◆ next_connection_id

next_connection_id

◆ opts

opts

◆ pid

pid

◆ sockets

sockets

The documentation for this class was generated from the following file: