code: def _emit_msg(self, msg):
      # If the previous message had an error, we want to prepend a "\n" to this message
      # to maximize the chance of this message being valid (for example, if the
      # previous message only partially sent for whatever reason, we want to "clear" it)
      msg = msg.serialize()
      if self._prev_message_error:
          msg = "\n" + msg
      msg_ser = msg.encode("utf-8")
      written_bytes = 0
      while written_bytes < len(msg_ser):
          # self._logger("Sent %d out of %d bytes" % (written_bytes, len(msg_ser)))
          try:
              fds = self._poller.poll(MESSAGE_WRITE_TIMEOUT_IN_MS)
              if fds is None or len(fds) == 0:
                  raise MsgTimeoutError("Poller timed out")
              for fd, event in fds:
                  if event & select.POLLERR:
                      raise PipeUnavailableError("Pipe unavailable")
                  f = os.write(fd, msg_ser[written_bytes:])
                  written_bytes += f
          except NullSidecarError:
              # sidecar is disabled, ignore all messages
              break
  
imports: from __future__ import print_function
  import subprocess
  import fcntl
  import select
  import os
  import sys
  import platform
  from fcntl import F_SETFL
  from os import O_NONBLOCK
  from .sidecar_messages import Message, MessageTypes
  from ..debug import debug
  from metaflow.tracing import inject_tracing_vars
label_desc: Use image node_id 8 for calling the SidecarSubProcess obj's underlying member method code with example usage: obj._emit_msg(msg) without return types