def reload_worker(self, json_request):
    """ Reloads taskqueue workers as needed.
        A worker can be started on both a master and slave node.
 
    Args:
      json_request: A JSON string with the application id.
    Returns:
      A JSON string with the error status and error reason.
    """
    request = self.__parse_json_and_validate_tags(json_request,  
                                         self.SETUP_WORKERS_TAGS)
    logging.info("Reload worker request: {0}".format(request))
    if 'error' in request:
      return json.dumps(request)

    app_id = self.__cleanse(request['app_id'])

    config = TaskQueueConfig(TaskQueueConfig.RABBITMQ, app_id)
    old_queues = self.__queue_info_cache.get(app_id, {'queue': []})
    old_queue_dict = {}
    for queue in old_queues['queue']:
      old_queue_dict[queue['name']] = queue

    new_queue_dict = {}
    # Load the new queue info.
    try:
      new_queues  = config.load_queues_from_file(app_id)
      for queue in new_queues['queue']:
        new_queue_dict[queue['name']] = queue
    except ValueError, value_error:
      return json.dumps({"error": True, "reason": str(value_error)}) 
    except NameError, name_error:
      return json.dumps({"error": True, "reason": str(name_error)}) 
    except Exception, exception:
      logging.error("******Unknown exception******")
      logging.exception(exception)
      return json.dumps({"error": True, "reason": str(exception)}) 
 

    reload_queues = False

    # Delete queues that no longer exist.
    for queue_name in old_queue_dict.keys():
      if queue_name not in new_queue_dict:
        logging.info("Deleting {0} queue: {1}".format(app_id, queue_name))
        reload_queues = True

    # Create any new queues.
    for queue_name in new_queue_dict.keys():
      if old_queue_dict.keys() not in queue_name:
        logging.info("Creating {0} queue: {1}".format(app_id, queue_name))
        reload_queues = True

    if reload_queues:
      logging.info("Old {0} queues: {1}".format(app_id, old_queue_dict))
      logging.info("New {0} queues: {1}".format(app_id, new_queue_dict))
      self.stop_worker(json_request)
      self.start_worker(json_request)
      self.__force_reload = True
    else:
      logging.info("Not reloading queues")
      self.__queue_info_cache[app_id] = new_queues

    json_response = {'error': False}
    return json.dumps(json_response)
dataset/ETHPy150Open AppScale/appscale/AppTaskQueue/distributed_tq.py/DistributedTaskQueue.reload_worker/swapped operands of `not in`