MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / AsyncConnection

Class AsyncConnection

pymongo/asynchronous/pool.py:115–653  ·  view source on GitHub ↗

Store a connection with some metadata. :param conn: a raw connection object :param pool: a Pool instance :param address: the server's (host, port) :param id: the id of this socket in it's pool :param is_sdam: SDAM connections do not call hello on creation

Source from the content-addressed store, hash-verified

113
114
115class AsyncConnection:
116 """Store a connection with some metadata.
117
118 :param conn: a raw connection object
119 :param pool: a Pool instance
120 :param address: the server's (host, port)
121 :param id: the id of this socket in it's pool
122 :param is_sdam: SDAM connections do not call hello on creation
123 """
124
125 def __init__(
126 self,
127 conn: AsyncNetworkingInterface,
128 pool: Pool,
129 address: tuple[str, int],
130 id: int,
131 is_sdam: bool,
132 ):
133 self.pool_ref = weakref.ref(pool)
134 self.conn = conn
135 self.address = address
136 self.id = id
137 self.is_sdam = is_sdam
138 self.closed = False
139 self.last_checkin_time = time.monotonic()
140 self.performed_handshake = False
141 self.is_writable: bool = False
142 self.max_wire_version = MAX_WIRE_VERSION
143 self.max_bson_size = MAX_BSON_SIZE
144 self.max_message_size = MAX_MESSAGE_SIZE
145 self.max_write_batch_size = MAX_WRITE_BATCH_SIZE
146 self.supports_sessions = False
147 self.hello_ok: bool = False
148 self.is_mongos = False
149 self.op_msg_enabled = False
150 self.listeners = pool.opts._event_listeners
151 self.enabled_for_cmap = pool.enabled_for_cmap
152 self.enabled_for_logging = pool.enabled_for_logging
153 self.compression_settings = pool.opts._compression_settings
154 self.compression_context: Union[SnappyContext, ZlibContext, ZstdContext, None] = None
155 self.socket_checker: SocketChecker = SocketChecker()
156 self.oidc_token_gen_id: Optional[int] = None
157 # Support for mechanism negotiation on the initial handshake.
158 self.negotiated_mechs: Optional[list[str]] = None
159 self.auth_ctx: Optional[_AuthContext] = None
160
161 # The pool's generation changes with each reset() so we can close
162 # sockets created before the last reset.
163 self.pool_gen = pool.gen
164 self.generation = self.pool_gen.get_overall()
165 self.ready = False
166 self.cancel_context: _CancellationContext = _CancellationContext()
167 self.opts = pool.opts
168 self.more_to_come: bool = False
169 # For load balancer support.
170 self.service_id: Optional[ObjectId] = None
171 self.server_connection_id: Optional[int] = None
172 # When executing a transaction in load balancing mode, this flag is

Callers 1

connectMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected