MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / unack_write

Method unack_write

pymongo/synchronous/client_bulk.py:320–407  ·  view source on GitHub ↗

A proxy for Connection.unack_write that handles event publishing.

(
        self,
        bwc: _ClientBulkWriteContext,
        cmd: MutableMapping[str, Any],
        request_id: int,
        msg: bytes,
        op_docs: list[Mapping[str, Any]],
        ns_docs: list[Mapping[str, Any]],
        client: MongoClient[Any],
    )

Source from the content-addressed store, hash-verified

318 return reply # type: ignore[return-value]
319
320 def unack_write(
321 self,
322 bwc: _ClientBulkWriteContext,
323 cmd: MutableMapping[str, Any],
324 request_id: int,
325 msg: bytes,
326 op_docs: list[Mapping[str, Any]],
327 ns_docs: list[Mapping[str, Any]],
328 client: MongoClient[Any],
329 ) -> Optional[Mapping[str, Any]]:
330 """A proxy for Connection.unack_write that handles event publishing."""
331 if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG):
332 _debug_log(
333 _COMMAND_LOGGER,
334 message=_CommandStatusMessage.STARTED,
335 clientId=client._topology_settings._topology_id,
336 command=cmd,
337 commandName=next(iter(cmd)),
338 databaseName=bwc.db_name,
339 requestId=request_id,
340 operationId=request_id,
341 driverConnectionId=bwc.conn.id,
342 serverConnectionId=bwc.conn.server_connection_id,
343 serverHost=bwc.conn.address[0],
344 serverPort=bwc.conn.address[1],
345 serviceId=bwc.conn.service_id,
346 )
347 if bwc.publish:
348 cmd = bwc._start(cmd, request_id, op_docs, ns_docs)
349 try:
350 result = bwc.conn.unack_write(msg, bwc.max_bson_size) # type: ignore[func-returns-value, misc, override]
351 duration = datetime.datetime.now() - bwc.start_time
352 if result is not None:
353 reply = _convert_write_result(bwc.name, cmd, result) # type: ignore[arg-type]
354 else:
355 # Comply with APM spec.
356 reply = {"ok": 1}
357 if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG):
358 _debug_log(
359 _COMMAND_LOGGER,
360 message=_CommandStatusMessage.SUCCEEDED,
361 clientId=client._topology_settings._topology_id,
362 durationMS=duration,
363 reply=reply,
364 commandName=next(iter(cmd)),
365 databaseName=bwc.db_name,
366 requestId=request_id,
367 operationId=request_id,
368 driverConnectionId=bwc.conn.id,
369 serverConnectionId=bwc.conn.server_connection_id,
370 serverHost=bwc.conn.address[0],
371 serverPort=bwc.conn.address[1],
372 serviceId=bwc.conn.service_id,
373 )
374 if bwc.publish:
375 bwc._succeed(request_id, reply, duration)
376 except Exception as exc:
377 duration = datetime.datetime.now() - bwc.start_time

Callers 1

_execute_batch_unackMethod · 0.95

Calls 8

_debug_logFunction · 0.90
_convert_write_resultFunction · 0.90
_convert_exceptionFunction · 0.90
nextFunction · 0.85
iterFunction · 0.85
_succeedMethod · 0.80
_failMethod · 0.80
_startMethod · 0.45

Tested by

no test coverage detected