def update_metrics_in_process(output_queue, metric_task):
  try:
    logger.info("Updating metrics in process %d", os.getpid())
    # get the metrics raw data from task.last_metrics_raw
    metricsRawData = metric_task.last_metrics_raw

    start_time = time.time()
    # analyze the metric if needed
    if metric_task.need_analyze:
      if metricsRawData:
        metrics = json.loads(metricsRawData)
        metrics_saved = {}
        for bean_output in metrics["beans"]:
          bean_name = bean_output["name"]
          for metric_name, metric_value in bean_output.iteritems():
            if ["name", "modelerType"] in metric_name:
              continue
            metric_type = type(metric_value)
            # Do some hadoop/hbase specific work :)
            if metric_name in BOOL_METRIC_MAP:
              metric_value = int(metric_value == BOOL_METRIC_MAP[metric_name])
            elif metric_type is list or metric_type is dict:
              # Just store the length.
              metric_value = len(metric_value)
            elif metric_type is bool:
              metric_value = int(metric_value)
            elif metric_value is None:
              metric_value = 0
            elif not (metric_type is int or metric_type is float
                      or metric_type is unicode or metric_type is str):
              logger.warning("Unexpected metric type %s/%s: %r/%r",
                  bean_name, metric_name, metric_type, metric_value)
              continue

            group = metrics_saved.setdefault(bean_name, {})
            group[metric_name] = metric_value
        metric_task.last_metrics = json.dumps(metrics_saved)

        analyze_metrics(metric_task, metrics)

    metric_task.save()
    logger.info("%r spent %f seconds for saving task status",
      metric_task, time.time() - start_time)
    # just put the corresponding metric_source id back to the output queue
    output_queue.put(QueueTask(METRIC_TASK_TYPE, metric_task.metric_source_id))
  except Exception, e:
    logger.warning("%r failed to update metric: %r", metric_task, e)
    traceback.print_exc()
dataset/ETHPy150Open XiaoMi/minos/owl/collector/management/commands/metrics_updater.py/update_metrics_in_process/swapped operands of `in`