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],
)
| 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 |
no test coverage detected