Esempio n. 1
0
class FeedbackProcessController(object):
    """Takes care of starting and stopping of Feedback Processes."""

    def __init__(self, plugindirs, baseclass, timeout):
        """Initialize the Feedback Process Controller."""
        # Where are we:
        # Proc/Thread: FB/??
        self.logger = logging.getLogger("FeedbackProcessController")
        self.currentProc = None
        self.timeout = timeout
        self.pluginController = PluginController(plugindirs, baseclass)

        self.pluginController.find_plugins()
        self.pluginController.unload_plugin()


    def start_feedback(self, name, port):
        """Starts the given Feedback in a new process."""
        self.logger.debug("Starting new Process...",)
        if self.currentProc:
            self.logger.warning("Trying to start feedback but another one is still running. Killing the old one now and proceed.")
            self.stop_feedback()
        ipcReady = Event()
        self.currentProc = FeedbackProcess(self.pluginController.availablePlugins[name], name, ipcReady, port)
        self.currentProc.start()
        # Wait until the network from the Process is ready, this is necessary
        # since spawning a new process under Windows is very slow.
        self.logger.debug("Waiting for IPC channel to become ready...")
        ipcReady.wait()
        self.logger.debug("IPC channel ready.")
        self.logger.debug("Done starting process.")


    def stop_feedback(self):
        """Stops the current Process.

        First it tries to join the process with the given timeout, if that fails
        it terminates the process the hard way.
        """
        self.logger.debug("Stopping process...",)
        if not self.currentProc:
            self.logger.debug("No process running, nothing to do.")
            return

        self.currentProc.join(self.timeout)
        if self.currentProc.is_alive():
            self.logger.warning("Process still alive, terminating it...",)
            self.currentProc.terminate()
            self.currentProc.join(self.timeout)
            if self.currentProc.is_alive():
                self.logger.error("Process still alive, giving up.")

        del(self.currentProc)
        self.currentProc = None
        self.logger.debug("Done stopping process.")


    def get_feedbacks(self):
        """Return a list of available Feedbacks."""
        return self.pluginController.availablePlugins.keys()
Esempio n. 2
0
class FeedbackProcessController(object):
    """Takes care of starting and stopping of Feedback Processes."""
    def __init__(self, plugindirs, baseclass, timeout):
        """Initialize the Feedback Process Controller."""
        # Where are we:
        # Proc/Thread: FB/??
        self.logger = logging.getLogger("FeedbackProcessController")
        self.currentProc = None
        self.timeout = timeout
        self.pluginController = PluginController(plugindirs, baseclass)

        self.pluginController.find_plugins()
        self.pluginController.unload_plugin()

    def start_feedback(self, name, port):
        """Starts the given Feedback in a new process."""
        self.logger.debug("Starting new Process...", )
        if self.currentProc:
            self.logger.warning(
                "Trying to start feedback but another one is still running. Killing the old one now and proceed."
            )
            self.stop_feedback()
        ipcReady = Event()
        self.currentProc = FeedbackProcess(
            self.pluginController.availablePlugins[name], name, ipcReady, port)
        self.currentProc.start()
        # Wait until the network from the Process is ready, this is necessary
        # since spawning a new process under Windows is very slow.
        self.logger.debug("Waiting for IPC channel to become ready...")
        ipcReady.wait()
        self.logger.debug("IPC channel ready.")
        self.logger.debug("Done starting process.")

    def stop_feedback(self):
        """Stops the current Process.

        First it tries to join the process with the given timeout, if that fails
        it terminates the process the hard way.
        """
        self.logger.debug("Stopping process...", )
        if not self.currentProc:
            self.logger.debug("No process running, nothing to do.")
            return

        self.currentProc.join(self.timeout)
        if self.currentProc.is_alive():
            self.logger.warning("Process still alive, terminating it...", )
            self.currentProc.terminate()
            self.currentProc.join(self.timeout)
            if self.currentProc.is_alive():
                self.logger.error("Process still alive, giving up.")

        del (self.currentProc)
        self.currentProc = None
        self.logger.debug("Done stopping process.")

    def get_feedbacks(self):
        """Return a list of available Feedbacks."""
        return self.pluginController.availablePlugins.keys()
Esempio n. 3
0
    def __init__(self, plugindirs, baseclass, timeout):
        """Initialize the Feedback Process Controller."""
        # Where are we:
        # Proc/Thread: FB/??
        self.logger = logging.getLogger("FeedbackProcessController")
        self.currentProc = None
        self.timeout = timeout
        self.pluginController = PluginController(plugindirs, baseclass)

        self.pluginController.find_plugins()
        self.pluginController.unload_plugin()
Esempio n. 4
0
    def __init__(self, plugindirs, baseclass, timeout):
        """Initialize the Feedback Process Controller."""
        # Where are we:
        # Proc/Thread: FB/??
        self.logger = logging.getLogger("FeedbackProcessController")
        self.currentProc = None
        self.timeout = timeout
        self.pluginController = PluginController(plugindirs, baseclass)

        self.pluginController.find_plugins()
        self.pluginController.unload_plugin()