コード例 #1
0
ファイル: longrunners.py プロジェクト: JPWKU/unix-agent
    def run(self):
        _g_logger.info("Job runner %s thread starting." % self.getName())

        done = False
        while not done:
            try:
                work = self._queue.get(True)
                if work.quit:
                    done = True
                    continue

                try:
                    _g_logger.debug("Running the long job %s:%s" %
                                    (work.name, work.request_id))

                    job_reply = JobReply(work.job_id)
                    dcm_events.register_callback(
                        self._job_update_callback, args=[job_reply])

                    plugin = plugin_loader.load_python_module(
                        work.items_map["module_name"],
                        self._conf,
                        work.request_id,
                        work.items_map,
                        work.name,
                        work.arguments)

                    reply_obj = plugin.run()
                    job_reply.reply_doc = reply_obj.get_reply_doc()
                except Exception as ex:
                    _g_logger.exception("An error occurred")
                    job_reply.error = str(ex)
                    job_reply.job_status = JobStatus.ERROR
                else:
                    if job_reply.reply_doc is None:
                        job_reply.job_status = JobStatus.COMPLETE
                    elif job_reply.reply_doc["return_code"] == 0:
                        job_reply.job_status = JobStatus.COMPLETE
                    else:
                        job_reply.job_status = JobStatus.ERROR
                        job_reply.error = job_reply.reply_doc["message"]
                finally:
                    job_reply.end_date = calendar.timegm(time.gmtime())
                    dcm_events.register_callback(
                        self._job_update_callback, args=[job_reply])
                    _g_logger.debug("Completed the long job %s:%s "
                                    "STATUS=%s" % (work.name, work.request_id,
                                                   job_reply.job_status))

            except queue.Empty:
                _g_logger.exception("The queue was empty.  This shouldn't "
                                    "happen often")
            except Exception as ex:
                _g_logger.exception("Something went wrong processing the job")
            finally:
                self._current_job = None

        _g_logger.info("Job runner %s thread ending." % self.getName())
コード例 #2
0
ファイル: longrunners.py プロジェクト: QSFT/unix-agent
    def run(self):
        _g_logger.info("Job runner %s thread starting." % self.getName())

        done = False
        while not done:
            try:
                work = self._queue.get(True)
                if work.quit:
                    done = True
                    continue

                try:
                    _g_logger.debug("Running the long job %s:%s" %
                                    (work.name, work.request_id))

                    job_reply = JobReply(work.job_id)
                    dcm_events.register_callback(self._job_update_callback,
                                                 args=[job_reply])

                    plugin = plugin_loader.load_python_module(
                        work.items_map["module_name"], self._conf,
                        work.request_id, work.items_map, work.name,
                        work.arguments)

                    reply_obj = plugin.run()
                    job_reply.reply_doc = reply_obj.get_reply_doc()
                except Exception as ex:
                    _g_logger.exception("An error occurred")
                    job_reply.error = str(ex)
                    job_reply.job_status = JobStatus.ERROR
                else:
                    if job_reply.reply_doc is None:
                        job_reply.job_status = JobStatus.COMPLETE
                    elif job_reply.reply_doc["return_code"] == 0:
                        job_reply.job_status = JobStatus.COMPLETE
                    else:
                        job_reply.job_status = JobStatus.ERROR
                        job_reply.error = job_reply.reply_doc["message"]
                finally:
                    job_reply.end_date = calendar.timegm(time.gmtime())
                    dcm_events.register_callback(self._job_update_callback,
                                                 args=[job_reply])
                    _g_logger.debug(
                        "Completed the long job %s:%s "
                        "STATUS=%s" %
                        (work.name, work.request_id, job_reply.job_status))

            except queue.Empty:
                _g_logger.exception("The queue was empty.  This shouldn't "
                                    "happen often")
            except Exception as ex:
                _g_logger.exception("Something went wrong processing the job")
            finally:
                self._current_job = None

        _g_logger.info("Job runner %s thread ending." % self.getName())
コード例 #3
0
ファイル: longrunners.py プロジェクト: JPWKU/unix-agent
    def start_new_job(self, conf, request_id, items_map,
                      name, arguments):
        module_name = items_map["module_name"]

        plugin = plugin_loader.load_python_module(
            module_name, conf, request_id, items_map, name, arguments)

        with self._lock:
            self._job_id += 1
            new_job = NewLongJob(
                items_map, name, arguments, self._job_id, request_id)
            detached_job = DetachedJob(self._conf, self._job_id,
                                       plugin, name, arguments)
            self._job_table[detached_job.get_job_id()] = detached_job
            _g_logger.debug("Starting new long job id=%s"
                            % str(detached_job.get_job_id()))
            self._run_queue.put(new_job)
            return detached_job
コード例 #4
0
ファイル: longrunners.py プロジェクト: QSFT/unix-agent
    def start_new_job(self, conf, request_id, items_map, name, arguments):
        module_name = items_map["module_name"]

        plugin = plugin_loader.load_python_module(module_name, conf,
                                                  request_id, items_map, name,
                                                  arguments)

        with self._lock:
            self._job_id += 1
            new_job = NewLongJob(items_map, name, arguments, self._job_id,
                                 request_id)
            detached_job = DetachedJob(self._conf, self._job_id, plugin, name,
                                       arguments)
            self._job_table[detached_job.get_job_id()] = detached_job
            _g_logger.debug("Starting new long job id=%s" %
                            str(detached_job.get_job_id()))
            self._run_queue.put(new_job)
            return detached_job