code: def dispatch(self, value, callback=None):
          
  
          done = None
  
          if callback is None:
              done = threading.Event()
              shared_data = [None, None]
  
              def _callback(exc_info, return_value):
                  shared_data[0] = exc_info
                  shared_data[1] = return_value
  
                  done.set()
  
              callback = _callback
  
          workitem = WorkItem(value, callback)
          self._work_queue.put(workitem)
          if done is None:
              return None
  
          done.wait()
          exc_info, return_value = shared_data
          if exc_info is not None:
              self.future_raise(*exc_info)
  
          return return_value
docs: Dispatch an item to the workqueue and optionally wait.
  
          This is the only way to add work to the background work queue. Unless
          you also pass a callback object, this method will synchronously wait
          for the work to finish and return the result. If the work raises an
          exception, the exception will be reraised in this method.
  
          If you pass an optional callback(exc_info, return_value), this method
          will not block and instead your callback will be called when the work
          finishes.  If an exception was raised during processing, exc_info will
          be set with the contents of sys.exc_info().  Otherwise, exc_info will
          be None and whatever the work_queue handler returned will be passed as
          the return_value parameter to the supplied callback.
  
          Args:
              value (object): Arbitrary object that will be passed to the work
                  queue handler.
  
              callback (callable): Optional callback to receive the result of
                  the work queue when it finishes.  If not passed, this method
                  will be synchronous and return the result from the dispatch()
                  method itself
  
          Returns:
              object: The result of the work_queue handler function or None.
  
              If callback is not None, then this method will return immediately
              with a None return value.  Otherwise it will block until the work
              item is finished (including any work items ahead in the queue) and
              return whatever the work item handler returned.