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

Method unack_write

pymongo/asynchronous/bulk.py:329–415  ·  view source on GitHub ↗

A proxy for AsyncConnection.unack_write that handles event publishing.

(
        self,
        bwc: _BulkWriteContext,
        cmd: MutableMapping[str, Any],
        request_id: int,
        msg: bytes,
        max_doc_size: int,
        docs: list[Mapping[str, Any]],
        client: AsyncMongoClient[Any],
    )

Source from the content-addressed store, hash-verified

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