code: def _work_function(job_q: Queue, result_q: Queue, error_q: Queue) -> None:
      
      while True:
          job = job_q.get()
  
          if isinstance(job, _ThreadPoolSentinel):
              # All the work is done, get out
              result_q.put(_ThreadPoolSentinel())
              error_q.put(_ThreadPoolSentinel())
              job_q.task_done()
              break
  
          work_function = job[0]
          args = job[1]
          try:
              result = work_function(*args)
          except Exception as e:
              error_q.put((job, e))
          else:
              result_q.put((job, result))
          finally:
              job_q.task_done()
docs: Work function expected to run within threads.