

@util.debuglog
@gen.coroutine
def _stop(self, close_output_streams=False, for_shutdown=False):
    if self.is_stopped():
        return
    self._status = 'stopping'
    skip = (for_shutdown and self.use_papa)
    if (not skip):
        logger.debug(('stopping the %s watcher' % self.name))
        logger.debug(('gracefully stopping processes [%s] for %ss' % (self.name, self.graceful_timeout)))
        self.call_hook('before_stop')
        (yield self.kill_processes())
        self.reap_processes()
    if self.stream_redirector:
        self.stream_redirector.stop()
        self.stream_redirector = None
    if close_output_streams:
        if (self.stdout_stream and hasattr(self.stdout_stream, 'close')):
            self.stdout_stream.close()
        if (self.stderr_stream and hasattr(self.stderr_stream, 'close')):
            self.stderr_stream.close()
    if close_output_streams:
        logger.info('%s left running in papa', self.name)
    else:
        if (self.evpub_socket is not None):
            self.notify_event('stop', {
                'time': time.time(),
            })
        self._status = 'stopped'
        self.call_hook('after_stop')
        logger.info('%s stopped', self.name)

dataset/ETHPy150Open circus-tent/circus/circus/watcher.py Watcher._stop/VarMisuse@202/282 `skip`->`close_output_streams`