Stop the workers
@param $n - integer - number of workers to stop
@return boolean - success
178522
protected function stopWorkers($n = 1)
    {
        Daemon::log('--' . $n . '-- ' . Debug::backtrace() . '-----');

        $n = (int)$n;
        $i = 0;

        foreach ($this->workers->threads as &$w) {
            if ($i >= $n) {
                break;
            }

            if ($w->shutdown) {
                continue;
            }

            if ($w->reloaded) {
                continue;
            }

            $w->stop();
            ++$i;
        }

        $this->lastMpmActionTs = microtime(true);
        return true;
    }
1331588
public function skip($n)
    {
        return new Enumerator(
            function () use($n) {
                foreach ($this->each() as $v) {
                    if (0 < $n) {
                        -- $n;
                    } else {
                        yield $v;
                    }
                }
            }
        );
    }
553521
public function stopProcess()
    {
        $this->isCurrentOsSupported('Only on *nix-based systems process cna be destroyed. You are running "%s".');
        try {
            $result = shell_exec(sprintf('kill %d 2>&1', $this->pid));
            if (!preg_match('/No such process/', $result)) {
                return true;
            }
        } catch (Exception $e) {

        }

        return false;
    }
479567
public function stop($queueName)
    {
        return (bool)$this->getRedis()->hset($this->getRedisQueueStopNamespace(), $queueName, true);
    }
807011
function stop() {
        if($this->timer) {
            self::$loop->cancelTimer($this->timer);
            $this->timer = null;
        }
        
        $this->emitter->removeListener($this->event, $this->listener);
        
        $errors = (array) ($this->options['errors'] ?? array());
        if(\in_array('max', $errors, true) && ($this->options['max'] ?? 0) > 0 && $this->bucket->count() < $this->options['max']) {
            $reject = $this->reject;
            $reject(new \RangeException('Collecting timed out (max not reached in time)'));
            return;
        }
        
        $resolve = $this->resolve;
        $resolve($this->bucket);
    }
700500
public function stop()
    {
        if (!$this->running) {
            return;
        }

        $this->running = false;

        $promise = call(function () {
            $promises = [];
            foreach (clone $this->workers as $worker) {
                \assert($worker instanceof Internal\IpcParent);
                $promises[] = call(function () use ($worker) {
                    list($process, $promise) = $this->workers[$worker];
                    \assert($process instanceof Process);

                    try {
                        yield $worker->shutdown();
                        yield Promise\timeout($promise, self::WORKER_TIMEOUT);
                    } catch (ContextException $exception) {
                        // Ignore if the worker has already died unexpectedly.
                    } finally {
                        if ($process->isRunning()) {
                            $process->kill();
                        }
                    }
                });
            }

            list($exceptions) = yield Promise\any($promises);

            $this->workers = new \SplObjectStorage;

            if (!empty($exceptions)) {
                $exception = new MultiReasonException($exceptions);
                $message = \implode('; ', \array_map(function (\Throwable $exception): string {
                    return $exception->getMessage();
                }, $exceptions));
                throw new ClusterException("Stopping the cluster failed: " . $message, 0, $exception);
            }
        });

        $this->deferred->resolve($promise);
    }
1172596
public function stop()
    {
        $data = fb_get_code_coverage($this->_config['cleanup']);
        fb_disable_code_coverage();

        $result = [];
        foreach ($data as $file => $coverage) {
            foreach ($coverage as $line => $value) {
                if ($line && $value !== -2) {
                    $result[$file][$line - 1] = $value === -1 ? 0 : $value;
                }
            }
        }
        return $result;
    }
1339433
def do_stop_workers(self):
        
        logger.info("Stopping all workers (%d)", len(self.workers))
        for worker in list(self.workers.values()):
            try:
                logger.info(" - stopping '%s'", worker.get_id())
                worker.terminate()
                worker.join(timeout=1)
                logger.info(" - stopped")
            # A already dead worker or in a worker
            except (AttributeError, AssertionError):
                pass
            except Exception as exp:  # pylint: disable=broad-except
                logger.error("exception: %s", str(exp))
16493
public function limit(int $n): self
    {
        return new self(new Limit($this->getIterator(), 0, $n), $this->type);
    }
744848
protected function stopIfNecessary(WorkerOptions $options, $lastRestart, $job = null)
    {
        if ($this->shouldQuit) {
            $this->stop();
        } elseif ($this->memoryExceeded($options->memory)) {
            $this->stop(12);
        } elseif ($this->queueShouldRestart($lastRestart)) {
            $this->stop();
        } elseif ($options->stopWhenEmpty && is_null($job)) {
            $this->stop();
        }
    }
252379
public function writeLong($n)
    {
        $this->flushBits();
        $this->out .= implode('', Writer::chrByteSplit($n, 4));
        return $this;
    }
884224
public function terminate($status = 0)
    {
        $this->working = false;

        // We will mark this supervisor as terminating so that any user interface can
        // correctly show the supervisor's status. Then, we will scale the process
        // pools down to zero workers to gracefully terminate them all out here.
        app(SupervisorRepository::class)->forget($this->name);

        $this->processPools->each(function ($pool) {
            $pool->processes()->each(function ($process) {
                $process->terminate();
            });
        });

        if ($this->shouldWait()) {
            while ($this->processPools->map->runningProcesses()->collapse()->count()) {
                sleep(1);
            }
        }

        $this->exit($status);
    }
522072
public function stop()
    {
        $this->stopWorkerPools();
        $this->workerJobSocket->disconnect($this->config['sockets']['worker_job']);
        $this->workerReplySocket->close();
        $this->clientSocket->close();
        $this->loop->stop();
    }
266872
def _dismiss_worker(self, worker):
        """"""
        self._workers.remove(worker)
        if len(self._workers) < self._min_workers:
            self._workers.add(worker)
            return False
        return True
816876
protected function stop()
    {
        $pid = $this->getCurrentPid();

        if (! $this->isRunning($pid)) {
            $this->error("Failed! There is no swoole_http_server process running.");

            return;
        }

        $this->info('Stopping swoole http server...');

        $isRunning = $this->killProcess($pid, SIGTERM, 15);

        if ($isRunning) {
            $this->error('Unable to stop the swoole_http_server process.');

            return;
        }

        // I don't known why Swoole didn't trigger "onShutdown" after sending SIGTERM.
        // So we should manually remove the pid file.
        $this->removePidFile();

        $this->info('> success');
    }
47829
public function stop($quit = true): int
    {
        if (!$masterPid = $this->getPidFromFile(true)) {
            return Show::error("The swoole server({$this->name}) is not running.");
        }

        // Show::write("The swoole server({$this->name}:{$masterPid}) process stopping ", false);

        ProcessUtil::killAndWait($masterPid, $error = null, $this->name);

        if ($error) {
            return Show::error($error);
        }

        ServerUtil::removePidFile($this->pidFile);

        // stop success
        return Show::write("The swoole server({$this->name}) process stop success", $quit);
    }
1113473
def stop(self, terminate=False):
        

        if not self.__online:
            raise foundations.exceptions.ServerOperationError(
                "{0} | '{1}' TCP Server is not online!".format(self.__class__.__name__, self))

        if not terminate:
            self.__server.shutdown()
        else:
            self.__server._BaseServer__shutdown_request = True

        self.__server = None
        self.__worker = None
        self.__online = False

        LOGGER.info("{0} | TCP Server successfully stopped!".format(self.__class__.__name__))
        return True