예제 #1
0
파일: thread.py 프로젝트: e0ne/fuel-web
    def __init__(self):
        threading.Thread.__init__(self)
        self._stop = threading.Event()
        self.queue = get_queue()

        from nailgun.plugin.manager import PluginManager
        self.plugin_manager = PluginManager()
예제 #2
0
파일: thread.py 프로젝트: e0ne/fuel-web
    def __init__(self):
        threading.Thread.__init__(self)
        self._stop = threading.Event()
        self.queue = get_queue()

        from nailgun.plugin.manager import PluginManager
        self.plugin_manager = PluginManager()
예제 #3
0
파일: thread.py 프로젝트: mahak/fuelweb
class PluginThread(threading.Thread):
    """
    Separate thread. When plugin added in the queue
    thread started to processing plugin
    """
    def __init__(self):
        threading.Thread.__init__(self)
        self._stop = threading.Event()
        self.queue = get_queue()

        from nailgun.plugin.manager import PluginManager
        self.plugin_manager = PluginManager()

    def soft_stop(self):
        self._stop.set()

    @property
    def stopped(self):
        return self._stop.isSet()

    def run(self):
        while not self.stopped:
            task_uuid = None
            try:
                if not self.queue.empty():
                    task_uuid = self.queue.get_nowait()
                    self.plugin_manager.process(task_uuid)
            except Exception as exc:
                if task_uuid:
                    self.set_error(task_uuid, exc)
                logger.error(traceback.format_exc())

            if self.queue.empty():
                time.sleep(1)

    def set_error(self, task_uuid, msg):
        db().query(Task).filter_by(uuid=task_uuid).update({
            'status': 'error',
            'progress': 100,
            'message': str(msg)
        })
        db().commit()
예제 #4
0
class PluginThread(threading.Thread):
    """
    Separate thread. When plugin added in the queue
    thread started to processing plugin
    """
    def __init__(self):
        threading.Thread.__init__(self)
        self._stop = threading.Event()
        self.queue = get_queue()

        from nailgun.plugin.manager import PluginManager
        self.plugin_manager = PluginManager()

    def soft_stop(self):
        self._stop.set()

    @property
    def stopped(self):
        return self._stop.isSet()

    def run(self):
        while not self.stopped:
            task_uuid = None
            try:
                if not self.queue.empty():
                    task_uuid = self.queue.get_nowait()
                    self.plugin_manager.process(task_uuid)
            except Exception as exc:
                if task_uuid:
                    self.set_error(task_uuid, exc)
                logger.error(traceback.format_exc())

            if self.queue.empty():
                time.sleep(1)

    def set_error(self, task_uuid, msg):
        db().query(Task).filter_by(uuid=task_uuid).update({
            'status': 'error',
            'progress': 100,
            'message': str(msg)})
        db().commit()
예제 #5
0
파일: plugin.py 프로젝트: mydaisy2/fuelweb
    def POST(self):
        plugin_manager = PluginManager()
        task = plugin_manager.add_install_plugin_task(
            json.loads(web.data()))

        return TaskHandler.render(task)
예제 #6
0
    def POST(self):
        plugin_manager = PluginManager()
        task = plugin_manager.add_install_plugin_task(json.loads(web.data()))

        return TaskHandler.render(task)