code: def main():
      #
      # For OS/X set up the UI elements that users expect from
      # an app.
      #
      if sys.platform == "darwin":
          import os.path
  
          icon_path = pkg_resources.resource_filename(
              "cellprofiler",
              os.path.join("data", "icons", "CellProfiler.png"),
          )
          os.environ["APP_NAME_%d" % os.getpid()] = "CellProfilerWorker"
          os.environ["APP_ICON_%d" % os.getpid()] = icon_path
  
      # Start the JVM
      from cellprofiler_core.utilities.java import start_java, stop_java
  
      with zmq.Context() as the_zmq_context:
          the_zmq_context.setsockopt(zmq.LINGER, 0)
          deadman_start_socket = the_zmq_context.socket(zmq.PAIR)
          deadman_start_socket.bind(DEADMAN_START_ADDR)
  
          # Start the deadman switch thread.
          monitor_thread = threading.Thread(
              target=monitor_keepalive,
              args=(
                  the_zmq_context,
                  notify_address,
              ),
              name="heartbeat_monitor",
              daemon=True,
          )
          monitor_thread.start()
  
          deadman_start_socket.recv()
          deadman_start_socket.close()
  
          from cellprofiler.knime_bridge import KnimeBridgeServer
  
          with Worker(
              the_zmq_context,
              analysis_id,
              work_server_address,
              notify_address,
          ) as worker:
              worker_thread = threading.Thread(
                  target=worker.run,
                  name="WorkerThread",
                  daemon=True,
              )
              worker_thread.start()
              with KnimeBridgeServer(
                  the_zmq_context,
                  knime_bridge_address,
                  NOTIFY_ADDR,
                  NOTIFY_STOP,
              ):
                  worker_thread.join()
              the_zmq_context.destroy(linger=0)
          LOGGER.debug("Worker thread joined")
          #
          # Shutdown - need to handle some global cleanup here
          #
          try:
              stop_java()
          except:
              LOGGER.warning("Failed to stop the JVM", exc_info=True)
  
file_path: CellProfiler/src/subpackages/core/cellprofiler_core/worker/__init__.py
imports: import logging
  import os
  import sys
  import psutil
  import pkg_resources
  from cellprofiler_core.constants.worker import DEADMAN_START_ADDR, DEADMAN_START_MSG, NOTIFY_STOP, all_measurements, NOTIFY_ADDR
  from cellprofiler_core.preferences import set_always_continue, set_conserve_memory
  from cellprofiler_core.worker._worker import Worker
  import time
  import threading
  import zmq
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: main() without return types