code: def process_messages(worker_type, worker):
      while True:
          try:
              msg = sys.stdin.readline().strip()
              if msg:
                  parsed_msg = Message.deserialize(msg)
                  if parsed_msg.msg_type == MessageTypes.INVALID:
                      print(
                          "[sidecar:%s] Invalid message -- skipping: %s"
                          % (worker_type, str(msg))
                      )
                      continue
                  else:
                      worker.process_message(parsed_msg)
                      if parsed_msg.msg_type == MessageTypes.SHUTDOWN:
                          break
              else:
                  break
  
          except:  # todo handle other possible exceptions gracefully
              print(
                  "[sidecar:%s]: %s"
                  % (worker_type, traceback.format_exc()),
                  file=sys.stderr,
              )
              break
      try:
          worker.shutdown()
      except:
          pass
  
file_path: metaflow/metaflow/sidecar/sidecar_worker.py
imports: from __future__ import print_function
  import os
  import sys
  import traceback
  from metaflow.sidecar import Message, MessageTypes
  from metaflow.plugins import SIDECARS
  from metaflow._vendor import click
  import metaflow.tracing
label_desc: Use image node_id 1 for calling a global function with example usage: process_messages(worker_type, worker) without return types