How to use the circus.util.debuglog function in circus

To help you get started, we’ve selected a few circus examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github circus-tent / circus / circus / process.py View on Github external
    @debuglog
    def stop(self):
        """Terminate the process."""
        if self._worker.poll() is None:
            return self._worker.terminate()
github circus-tent / circus / circus / watcher.py View on Github external
    @util.debuglog
    def spawn_processes(self):
        """Spawn processes.
        """
        # when an on_demand process dies, do not restart it until
        # the next event
        if self.on_demand and not self.arbiter.socket_event:
            self.stopped = True
            return
        for i in range(self.numprocesses - len(self.processes)):
            self.spawn_process()
            time.sleep(self.warmup_delay)
github circus-tent / circus / circus / watcher.py View on Github external
    @util.debuglog
    def process_info(self, pid):
        process = self.processes[int(pid)]
        return process.info()
github circus-tent / circus / circus / watcher.py View on Github external
    @util.debuglog
    def kill_process(self, process, stop_signal=None, graceful_timeout=None):
        """Kill process (stop_signal, graceful_timeout then SIGKILL)
        """
        if stop_signal is None:
            stop_signal = self.stop_signal
        if graceful_timeout is None:
            graceful_timeout = self.graceful_timeout

        if process.stopping:
            raise gen.Return(False)
        try:
            logger.debug("%s: kill process %s", self.name, process.pid)
            if self.stop_children:
                self.send_signal_process(process, stop_signal)
            else:
                self.send_signal(process.pid, stop_signal)
github circus-tent / circus / circus / process.py View on Github external
    @debuglog
    def poll(self):
        return self._worker.poll()
github circus-tent / circus / circus / arbiter.py View on Github external
    @debuglog
    def start(self):
        """Starts all the watchers.

        The start command is an infinite loop that waits
        for any command from a client and that watches all the
        processes and restarts them if needed.
        """
        logger.info("Starting master on pid %s", self.pid)
        self.initialize()

        # start controller
        self.ctrl.start()
        try:
            # initialize processes
            logger.debug('Initializing watchers')
            for watcher in self.iter_watchers():
github circus-tent / circus / circus / watcher.py View on Github external
    @util.debuglog
    def reap_processes(self):
        """Reap all the processes for this watcher.
        """
        if self.stopped:
            logger.debug('do not reap processes as the watcher is stopped')
            return

        # reap_process changes our dict, look through the copy of keys
        for pid in self.processes.keys():
            self.reap_process(pid)
github circus-tent / circus / circus / watcher.py View on Github external
    @util.debuglog
    def _start(self):
        """Start.
        """
        if self.pending_socket_event:
            return

        if not self.is_stopped():
            if len(self.processes) < self.numprocesses:
                self.reap_processes()
                yield self.spawn_processes()
            return

        found_wids = len(self._found_wids)
        if not self._found_wids and not self.call_hook('before_start'):
            logger.debug('Aborting startup')
            return
github circus-tent / circus / circus / watcher.py View on Github external
    @util.debuglog
    def reap_process(self, pid, status=None):
        """ensure that the process is killed (and not a zombie)"""
        if pid not in self.processes:
            return

        # We ignore the hook result
        self.call_hook("before_reap", process_pid=pid, time=time.time())

        process = self.processes.pop(pid)

        timeout = 0.001

        while status is None:
            if IS_WINDOWS:
                try:
                    # On Windows we can't use waitpid as it's blocking,
github circus-tent / circus / circus / plugins / __init__.py View on Github external
    @debuglog
    def stop(self):
        if not self.running:
            self.loop.close()
            return

        try:
            self.handle_stop()
        finally:
            self.loop.stop()

        self.running = False