|
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) |
|
◆ __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__()
◆ close()
◆ 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()
◆ 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.
◆ active_sockets
◆ address
◆ closed
◆ enabled_for_cmap
◆ generation
◆ handshake
◆ is_writable
◆ lock
◆ next_connection_id
◆ opts
◆ pid
◆ sockets
The documentation for this class was generated from the following file:
- /home/passerat/Stage/flaskProject/venv/lib/python3.8/site-packages/pymongo/pool.py