def run()

in benchmarking/run_lab.py [0:0]


    def run(self):
        # set env vars of this process and any subprocess for logging.
        os.environ["JOB_IDENTIFIER"] = str(self.job["identifier"])
        os.environ["JOB_ID"] = str(self.job["id"])
        handlers = []
        log_capture_string = StringIO()
        ch = logging.StreamHandler(log_capture_string)
        ch.setLevel(logging.DEBUG)
        getLogger().addHandler(ch)
        handlers.append(ch)
        # if enabled realtime logger will also update the log entry at regualr intervals.
        if self.args.rt_logging:
            dbh = DBLogUpdateHandler(
                self.db, self.job["id"], self.args.rt_logging_interval
            )
            dbh.setLevel(logging.DEBUG)
            getLogger().addHandler(dbh)
            handlers.append(dbh)
            getLogger().info(
                "Realtime logging enabled with {}s updates.".format(
                    self.args.rt_logging_interval
                )
            )
        try:
            self._setFramework()
            with LOCK:
                getLogger().info(
                    f"Lock acquired by {os.getpid()} before _downloadFiles() for benchmark {self.job['identifier']} id ({self.job['id']})"
                )
                self._downloadFiles()
            raw_args = self._getRawArgs()
            app = BenchmarkDriver(raw_args=raw_args, usb_controller=self.usb_controller)
            getLogger().debug(
                f"Running BenchmarkDriver for benchmark {self.job['identifier']} id ({self.job['id']})"
            )
            status = app.run()

        except DownloadException:
            getLogger().critical(
                f"An error occurred while downloading files for benchmark {self.job['identifier']} id ({self.job['id']}",
                exc_info=True,
            )
            status = HARNESS_ERROR
        except BenchmarkArgParseException:
            getLogger().exception(
                f"An error occurred while parsing arguments for benchmark {self.job['identifier']} id ({self.job['id']})"
            )
            status = USER_ERROR
        except Exception:
            getLogger().critical(
                f"An error occurred while running benchmark {self.job['identifier']} id ({self.job['id']}",
                exc_info=True,
            )
            status = HARNESS_ERROR
        finally:
            output = log_capture_string.getvalue()
            log_capture_string.close()
            for handler in handlers:
                handler.close()
                getLogger().handlers.remove(handler)
            del handlers
            self._setStatusOutput(status, output)
            self._submitDone()
            self._removeBenchmarkFiles()
            time.sleep(1)

        return {"device": self.device, "job": self.job}