code: def _worker(executor, work_queue):
      thread_state.proceed = True
      thread_state.executor = executor
  
      try:
          while thread_state.proceed:
              with executor._rejoin_lock:
                  if executor._rejoin_list:
                      (
                          rejoin_thread,
                          rejoin_event,
                      ) = executor._rejoin_list.pop()
                      executor._threads.add(rejoin_thread)
                      executor._threads.remove(
                          threading.current_thread()
                      )
                      rejoin_event.set()
                      break
              try:
                  task = work_queue.get(timeout=1)
              except queue.Empty:
                  continue
              if task is not None:  # sentinel
                  task.run()
                  del task
              elif (
                  thread._shutdown
                  or executor is None
                  or executor._shutdown
              ):
                  work_queue.put(None)
                  return
          del executor
      except BaseException:
          logger.critical("Exception in worker", exc_info=True)
      finally:
          del thread_state.proceed
          del thread_state.executor
  
file_path: distributed/distributed/threadpoolexecutor.py
imports: from __future__ import annotations
  import itertools
  import logging
  import os
  import queue
  import threading
  from distributed import _concurrent_futures_thread
  from distributed.metrics import time
label_desc: Use image node_id 1 for calling a global function with example usage: _worker(executor, work_queue) without return types