Setup provisions to watch a specified signal

        :param signal:
            The :class:`Signal` to watch for.

        After calling this method you can use :meth:`assertSignalFired()`
        and :meth:`assertSignalNotFired()` with the same signal.
485844
def watchSignal(self, signal):
        
        self._extend_state()

        def signal_handler(*args, **kwargs):
            self._events_seen.append((signal, args, kwargs))
        signal.connect(signal_handler)
        if hasattr(self, 'addCleanup'):
            self.addCleanup(signal.disconnect, signal_handler)
733523
def emit(self, arg=None):
        """"""
        for model,name in self.__get_models__():
            model.notify_signal_emit(name, arg)
1320743
def _add_observer(self, signal, observer):
        

        if observer not in self._observers[signal]:
            self._observers[signal].append(observer)
1104614
def _handle_signals(self):
        
        signal.signal(signal.SIGTERM, signal.SIG_DFL)
        signal.signal(signal.SIGINT, signal.SIG_IGN)
449653
def kill(self, signal=None):
        

        return self.client.api.kill(self.id, signal=signal)
1018639
def _signal(self, sig, pid=None):
        
        log = self._params.get('log', self._discard)
        if pid is None:
            pids = self.get_pids()
        else:
            pids = [pid]
        for pid in pids:
            try:
                os.kill(pid, sig)
                log.debug("Signalled '%s' pid %d with %s", self._name, pid, utils.signame(sig))
            except Exception as e:
                log.warning("Failed to signal '%s' pid %d with %s -- %s", self._name, pid, utils.signame(sig), e)
1300753
def monitor(self, message, *args, **kws):
    
    if self.isEnabledFor(MON):
        # Yes, logger takes its '*args' as 'args'.
        self._log(MON, message, args, **kws)
58715
def emit(self, signal, *args):
        
        callbacks = self._callbacks.get(signal, [])
        new_callbacks = []
        for callback in callbacks:
            # clear out deleted pointers
            if not callback.isValid():
                continue

            new_callbacks.append(callback)

            try:
                callback(*args)
            except StandardError:
                logger.exception('Error occurred during callback.')

        self._callbacks[signal] = new_callbacks
486740
def watch(self, signal_name):
		
		watcher = WSignalSource.Watcher(
			self.__queues[signal_name], lambda x: self.__watchers_callbacks[signal_name].remove(x)
		)
		self.__watchers_callbacks[signal_name].add(watcher)
		return watcher
967896
def setup_signal_handlers(self):
        ''''''
        if platform.system() == 'Windows':
            _logger.warning(_(
                'Graceful stopping with Unix signals is not supported '
                'on this OS.'
            ))
            return

        event_loop = asyncio.get_event_loop()
        graceful_called = False

        def graceful_stop_callback():
            nonlocal graceful_called

            if graceful_called:
                forceful_stop_callback()
                return

            graceful_called = True

            _logger.info(_('Stopping once all requests complete...'))
            _logger.info(_('Interrupt again to force stopping immediately.'))
            self.stop()

        def forceful_stop_callback():
            _logger.info(_('Forcing immediate stop...'))
            logging.raiseExceptions = False
            event_loop.stop()

        event_loop.add_signal_handler(signal.SIGINT, graceful_stop_callback)
        event_loop.add_signal_handler(signal.SIGTERM, forceful_stop_callback)
470743
def emit(self, signalName, *args, **kwargs):
        
        assert signalName in self, "%s is not a registered signal" % signalName
        self[signalName].emit(*args, **kwargs)
149403
def get(self, signal=None):
        
        return self.__app.signals.get(signal, self._plugin)
569706
def setup_signals
      Kernel.trap('INT')    { Thread.new { @shutdown.call(Signal.list['INT']) }.join }
      Kernel.trap('TERM')   { Thread.new { @shutdown.call(Signal.list['TERM']) }.join }
      unless RbConfig::CONFIG['host_os'] =~ /mswin|windows|cygwin/i
        Kernel.trap('HUP')  { Thread.new { @reload.call }.join }
      end
    end
444575
def send_signal(self, s):
        
        self._get_signal_event(s)  # Check if signal has been enabled
        pid = self.get_pid()
        if not pid:
            raise ValueError('Daemon is not running.')
        os.kill(pid, s)
23043
def add_signal(self, signal):
        """"""
        self.__signals.append(signal)
        if self.__connected:
            # Connects signal if the current state is "connected"
            self.__connect_signal(signal)
843741
def do_signal(self, signame: str) -> None:
        """"""
        if hasattr(signal, signame):
            os.kill(os.getpid(), getattr(signal, signame))
        else:
            self._sout.write('Unknown signal %s\n' % signame)
438053
def _connect_signals(self, model):
        
        for signal in self._signals:
            receiver = self._signals[signal]
            signal.connect(receiver, sender=model, dispatch_uid=self._dispatch_uid(signal, model))