code: def worker(f, ii, chunk, out_q, err_q, lock):
    
    vals = []
  
    # iterate over slice 
    for val in chunk:
      try:
        result = f(val)
      except Exception as e:
        err_q.put(e)
        return
  
      vals.append(result)
  
    # output the result and task ID to output queue
    out_q.put( (ii, vals) )
docs: A worker function that maps an input function over a
    slice of the input iterable.
  
    :param f  : callable function that accepts argument from iterable
    :param ii  : process ID
    :param chunk: slice of input iterable
    :param out_q: thread-safe output queue
    :param err_q: thread-safe queue to populate on exception
    :param lock : thread-safe lock to protect a resource
           ( useful in extending parallel_map() )