Private: send a signal to all the workers.
345267
def kill_all(signal)
      idle, running = partition_workers
      log "kill -#{signal} #{running.map { |r| r.pid }.inspect}"
      running.each { |worker| worker.kill(signal) }
    end
508339
def communicate(args):
  """"""
  if args.local:
    raise ValueError("The communicate command can only be used without the '--local' command line option")
  jm = setup(args)
  jm.communicate(job_ids=get_ids(args.job_ids))
1237503
def burn_down_workers(signal)
      loop do
        check_for_expired_workers
        write_procline('shutdown')
        SIGNAL_QUEUE.clear

        break if :no_child == reap_workers(Process::WNOHANG)
        kill_all(signal)

        sleep 1 # Don't kill any more often than every 1s.
        yawn 5
      end
      # One last time.
      reap_workers
    end
856776
def send(self, signal, **kwargs):
        
        return self.__app.signals.send(signal, plugin=self._plugin, **kwargs)
636580
def startAll(self):
		
		self.logger.info("Starting all workers...")

		for worker in self.getWorkers():
			process = self.getWorker(worker)
			self.logger.debug("Starting {0}".format(process.name))
			process.start()

		self.logger.info("Started all workers")
620904
def kill_all(self):
        ''''''
        while self._num_workers > 0 and self._worker_backend_socket.poll(1000):
            msg = self._worker_backend_socket.recv_pyobj()
            self._worker_backend_socket.send_pyobj(None)
            self._num_workers -= 1
            self.report(f'Kill {msg[1:]}')
        # join all processes
        [worker.join() for worker in self._workers]
1247733
def notify(self, msgtype, method, params):
        """"""
        self.dispatch.call(method, params)
176460
public function sendToAllProcess($data)
    {
        foreach ($this->map as $process){
            $process->sendMessage($data,$process->worker_id);
        }
    }
116882
public function stop()
    {
        $ResqueStatus = $this->ResqueStatus;

        $this->debug('Searching for active workers');
        $options = new SendSignalCommandOptions();
        $options->title = 'Stopping workers';
        $options->noWorkersMessage = 'There is no workers to stop';
        $options->allOption = 'Stop all workers';
        $options->selectMessage = 'Worker to stop';
        $options->actionMessage = 'stopping';
        $options->workers = call_user_func(self::$Resque_Worker. '::all');
        $options->signal = $this->input->getOption('force')->value === true ? 'TERM' : 'QUIT';
        $options->successCallback = function ($pid, $workerName) use ($ResqueStatus) {
            $ResqueStatus->removeWorker($pid);
        };
        $options->schedulerWorkerActionMessage = 'Stopping the Scheduler Worker';
        $options->schedulerWorkerAction = function($worker) use ($ResqueStatus) {
            $ResqueStatus->unregisterSchedulerWorker();
        };

        $this->sendSignal($options);
    }
1005347
function deliverMessage (message) {
  workerIterator((worker) => {
    if (this.process.pid === worker.process.pid) {
      return
    }
    debug('delivering message to %s', worker.process.pid)
    worker.send(message)
  })
}
729747
public function sigWakeUp()
    {
        $this->log('SIGPIPE received; attempting to wake up', Logger::DEBUG);
        $this->redis->establishConnection();

        Event::fire(Event::WORKER_WAKEUP, $this);
    }
105580
def monitor_workers
      setup_process_manager_signals
      logger.info('Starting workers monitoring code...')

      loop do
        logger.debug("Checking workers' health...")
        @worker_pools.values.each do |pool|
          break if shutdown?
          pool.check_workers
        end

        break if shutdown?
        logger.debug("Sleeping for #{@config['poll_period']} seconds...")
        sleep(@config['poll_period'])
      end

    ensure
      logger.info("Workers monitoring loop is finished, starting shutdown...")
      # Send out stop signals
      stop_workers(false)

      # Wait for all the workers to die
      unless wait_for_workers(@config['wait_period'])
        logger.info("Some workers are still alive after 10 seconds of waiting. Killing them...")
        stop_workers(true)
        wait_for_workers(5)
      end
    end
1169486
def send_notification(self, method, args, kwargs):
        """"""
        msg = dumps([1, method, args, kwargs])
        self.send(msg)
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
59854
public void signalAll()
    {
        if (!hasWaiters())
            return;

        // to avoid a race where the condition is not met and the woken thread managed to wait on the queue before
        // we finish signalling it all, we pick a random thread we have woken-up and hold onto it, so that if we encounter
        // it again we know we're looping. We reselect a random thread periodically, progressively less often.
        // the "correct" solution to this problem is to use a queue that permits snapshot iteration, but this solution is sufficient
        int i = 0, s = 5;
        Thread randomThread = null;
        Iterator<RegisteredSignal> iter = queue.iterator();
        while (iter.hasNext())
        {
            RegisteredSignal signal = iter.next();
            Thread signalled = signal.signal();

            if (signalled != null)
            {
                if (signalled == randomThread)
                    break;

                if (++i == s)
                {
                    randomThread = signalled;
                    s <<= 1;
                }
            }

            iter.remove();
        }
    }
171744
def signal_handler(self, *args):
        
        self.user_callback(self.signal, self.user_arg, *args)
1155363
def listen(cls, event, func):
        """"""
        signal(event).connect(func, sender=cls)