예제 #1
0
파일: timer.py 프로젝트: rvykydal/anaconda
    def cancel(self):
        """Cancel scheduled callback.

        This way the schedule_sec and schedule_msec repetition can be canceled.
        """
        source_remove(self._id)
        self._id = 0
예제 #2
0
    def _sigchld_handler(cls, num=None, frame=None):
        """Signal handler used with watchProcess"""
        # Check whether anything in the list of processes being watched has
        # exited. We don't want to call waitpid(-1), since that would break
        # anything else using wait/waitpid (like the subprocess module).
        exited_pids = []
        exit_statuses = []

        for child_pid in cls._forever_pids:
            try:
                pid_result, status = os.waitpid(child_pid, os.WNOHANG)
            except ChildProcessError:
                continue

            if pid_result:
                proc_name = cls._forever_pids[child_pid][0]
                exited_pids.append(child_pid)

                # Convert the wait-encoded status to the format used by subprocess
                if os.WIFEXITED(status):
                    sub_status = os.WEXITSTATUS(status)
                else:
                    # subprocess uses negative return codes to indicate signal exit
                    sub_status = -os.WTERMSIG(status)

                exit_statuses.append((proc_name, sub_status))

        for child_pid in exited_pids:
            if cls._forever_pids[child_pid][1]:
                source_remove(cls._forever_pids[child_pid][1])
            del cls._forever_pids[child_pid]

        if exit_statuses:
            cls._raise_exit_error(exit_statuses)
예제 #3
0
    def cancel(self):
        """Cancel scheduled callback.

        This way the schedule_sec and schedule_msec repetition can be canceled.
        """
        source_remove(self._id)
        self._id = 0
예제 #4
0
    def unwatch_process(cls, proc):
        """Unwatch a process watched by watchProcess.

        :param proc: The Popen object for the process.
        """
        if cls._forever_pids[proc.pid][1]:
            source_remove(cls._forever_pids[proc.pid][1])
        del cls._forever_pids[proc.pid]
예제 #5
0
 def cancel(self):
     """Cancel watching."""
     source_remove(self._id)
     self._id = 0
예제 #6
0
 def unwatch_all_processes(cls):
     """Clear the watched process list."""
     for child_pid in cls._forever_pids:
         if cls._forever_pids[child_pid][1]:
             source_remove(cls._forever_pids[child_pid][1])
     cls._forever_pids = {}