code: def _op_msg(flags, command, dbname, read_preference, slave_ok, check_keys,
              opts, ctx=None):
      
      command['$db'] = dbname
      if "$readPreference" not in command:
          if slave_ok and not read_preference.mode:
              command["$readPreference"] = (
                  ReadPreference.PRIMARY_PREFERRED.document)
          else:
              command["$readPreference"] = read_preference.document
      name = next(iter(command))
      try:
          identifier = _FIELD_MAP.get(name)
          docs = command.pop(identifier)
      except KeyError:
          identifier = ""
          docs = None
      try:
          if ctx:
              return _op_msg_compressed(
                  flags, command, identifier, docs, check_keys, opts, ctx)
          return _op_msg_uncompressed(
              flags, command, identifier, docs, check_keys, opts)
      finally:
          # Add the field back to the command.
          if identifier:
              command[identifier] = docs
docs: Get a OP_MSG message.