Esempio n. 1
0
    def shutdown(self):
        if not self._has_finished():
            (self.out, self.err) = self.popen.communicate(input="\n")
            maxtime = 5 # seconds
            time_expired = False
            initialtime = time.time()
            while not self._has_finished() and not time_expired:
                time.sleep(0.1)
                time_expired = time.time() > initialtime + maxtime
            if time_expired:
                killer.term(self.popen)
                initialtime = time.time()
                while not self._has_finished() and not time_expired:
                    time.sleep(0.1)
                    time_expired = time.time() > initialtime + maxtime
                if time_expired:
                    killer.kill(self.popen)
        else:
            try:
                self.out = self.popen.stdout.read()
                self.err = self.popen.stderr.read()
            except Exception as e:
                self.out = "Couldn't read process output: %s" % e
                self.err = "Couldn't read process output: %s" % e

        self.result = self.popen.wait()
        return self.result
Esempio n. 2
0
    def shutdown(self):
        if not self._has_finished():
            (self.out, self.err) = self.popen.communicate(input="\n")
            maxtime = 5  # seconds
            time_expired = False
            initialtime = time.time()
            while not self._has_finished() and not time_expired:
                time.sleep(0.1)
                time_expired = time.time() > initialtime + maxtime
            if time_expired:
                killer.term(self.popen)
                initialtime = time.time()
                while not self._has_finished() and not time_expired:
                    time.sleep(0.1)
                    time_expired = time.time() > initialtime + maxtime
                if time_expired:
                    killer.kill(self.popen)
        else:
            try:
                self.out = self.popen.stdout.read()
                self.err = self.popen.stderr.read()
            except Exception as e:
                self.out = "Couldn't read process output: %s" % e
                self.err = "Couldn't read process output: %s" % e

        self.result = self.popen.wait()
        return self.result
Esempio n. 3
0
    def launch(self):
        global_parser = ConfigurationParser.GlobalParser()
        global_configuration = global_parser.parse(self.config_dir)
        machine_configuration = global_configuration.machines.get(self.machine_name)
        if machine_configuration is None:
            raise Exception("Machine %s not found" % self.machine_name)

        self._create_socket()

        processes = []
        for instance_name in machine_configuration.instances:
            instance_config = machine_configuration.instances[instance_name]
            if isinstance(self.logging_file_config, dict):
                logging_file_config = self.logging_file_config[instance_name]
            else:
                logging_file_config = self.logging_file_config
            if self.debugger_ports is None:
                debugger_port = "None"
            else:
                debugger_port = self.debugger_ports.get(instance_name, "None")
            args = (
                "python",
                "-OO",
                __file__,
                self.config_dir,
                self.machine_name,
                instance_name,
                logging_file_config,
                str(self.waiting_port),
                str(debugger_port),
            )
            subprocess_kargs = dict(args=args, stdin=subprocess.PIPE)
            process = process_starter.start_process(instance_config.user, (), subprocess_kargs)
            processes.append(process)

        self.notify_and_wait()

        for process in processes:
            try:
                process.stdin.write("\n")
            except:
                pass

        self.wait_for_subprocesses(processes)

        if len(processes) > 0:
            for process in processes:
                killer.term(process)

        self.wait_for_subprocesses(processes)

        if len(processes) > 0:
            for process in processes:
                killer.kill(process)

        self.wait_for_subprocesses(processes)
Esempio n. 4
0
    def launch(self):
        global_parser = ConfigurationParser.GlobalParser()
        global_configuration = global_parser.parse(self.config_dir)
        machine_configuration = global_configuration.machines.get(
            self.machine_name)
        if machine_configuration is None:
            raise Exception("Machine %s not found" % self.machine_name)

        self._create_socket()

        processes = []
        for instance_name in machine_configuration.instances:
            instance_config = machine_configuration.instances[instance_name]
            if isinstance(self.logging_file_config, dict):
                logging_file_config = self.logging_file_config[instance_name]
            else:
                logging_file_config = self.logging_file_config
            if self.debugger_ports is None:
                debugger_port = "None"
            else:
                debugger_port = self.debugger_ports.get(instance_name, "None")
            args = ("python", "-OO", __file__, self.config_dir,
                    self.machine_name, instance_name, logging_file_config,
                    str(self.waiting_port), str(debugger_port))
            subprocess_kargs = dict(args=args, stdin=subprocess.PIPE)
            process = process_starter.start_process(instance_config.user, (),
                                                    subprocess_kargs)
            processes.append(process)

        self.notify_and_wait()

        for process in processes:
            try:
                process.stdin.write("\n")
            except:
                pass

        self.wait_for_subprocesses(processes)

        if len(processes) > 0:
            for process in processes:
                killer.term(process)

        self.wait_for_subprocesses(processes)

        if len(processes) > 0:
            for process in processes:
                killer.kill(process)

        self.wait_for_subprocesses(processes)