This function will be called when a graceful-stop is initiated.
960919
def graceful_stop(self, signal_number=None, stack_frame=None):
        
        stop_msg = "Hard" if self.shutdown else "Graceful"
        if signal_number is None:
            self.log.info("%s stop called manually. "
                          "Shutting down.", stop_msg)
        else:
            self.log.info("%s stop called by signal #%s. Shutting down."
                          "Stack Frame: %s",
                          stop_msg, signal_number, stack_frame)
        self.shutdown = True
        self.crawler_list.stop()
        self.daemon_list.stop()
        self.thread_event.set()
        return True
778650
@Handler(priority = -10000)
    public void onStop(Stop event) throws InterruptedException {
        synchronized (this) {
            if (runner == null) {
                return;
            }
            runner.interrupt();
            synchronized (this) {
                if (registered) {
                    unregisterAsGenerator();
                    registered = false;
                }
            }
            runner = null;
        }
    }
488717
@Override
    public void stop(){
        if (isStarted) {
            synchronized (this) {
                if (isStarted) {
                    if (getRegistrationService() instanceof Closable) {
                        ((Closable) getRegistrationService()).stop();
                    }
                    isStarted = false;
                }
            }
        }

    }
98735
def set_stop_handler(self):
        
        signal.signal(signal.SIGTERM, self.graceful_stop)
        signal.signal(signal.SIGABRT, self.graceful_stop)
        signal.signal(signal.SIGINT, self.graceful_stop)
1361255
public function onFinish()
    {
        Timer::remove($this->keepaliveTimer);
        if ($this->req !== null && $this->req instanceof Generic) {
            if (!$this->req->isFinished()) {
                $this->req->abort();
            }
        }
        $this->req = null;
    }
233450
public synchronized void onDataReceived() {
    stopwatch.reset().start();
    // We do not cancel the ping future here. This avoids constantly scheduling and cancellation in
    // a busy transport. Instead, we update the status here and reschedule later. So we actually
    // keep one sendPing task always in flight when there're active rpcs.
    if (state == State.PING_SCHEDULED) {
      state = State.PING_DELAYED;
    } else if (state == State.PING_SENT || state == State.IDLE_AND_PING_SENT) {
      // Ping acked or effectively ping acked. Cancel shutdown, and then if not idle,
      // schedule a new keep-alive ping.
      if (shutdownFuture != null) {
        shutdownFuture.cancel(false);
      }
      if (state == State.IDLE_AND_PING_SENT) {
        // not to schedule new pings until onTransportActive
        state = State.IDLE;
        return;
      }
      // schedule a new ping
      state = State.PING_SCHEDULED;
      checkState(pingFuture == null, "There should be no outstanding pingFuture");
      pingFuture = scheduler.schedule(sendPing, keepAliveTimeInNanos, TimeUnit.NANOSECONDS);
    }
  }
1353018
function(ev) {
      if(ev && ev.preventDefault) {
        ev.preventDefault();
      };
      if(ev && ev.stopPropagation) {
        ev.stopPropagation();
      };
    }
1182376
public function onFinish()
    {
        if ($this->eofTerminated) {
            $this->requestFinished();
            $this->onResponse->executeAll($this, false);
            parent::onFinish();
            return;
        }
        if ($this->protocolError) {
            $this->onResponse->executeAll($this, false);
        } else {
            if (($this->state !== self::STATE_ROOT) && !$this->onResponse->isEmpty()) {
                $this->requestFinished();
            }
        }
        parent::onFinish();
    }
668908
def stop(self):
        

        if self.original_handler is not None:
            signal.signal(signal.SIGWINCH, self.original_handler)
794774
public function gracefulShutdown()
    {
        if ((!$this->route) || $this->route->gracefulShutdown()) {
            $this->finish();
            return true;
        }
        return false;
    }
165542
def on_stop_scene(self, event: events.StopScene, signal: Callable[[Any], None]):
        
        self.stop_scene()
        if self.current_scene is not None:
            signal(events.SceneContinued())
        else:
            signal(events.Quit())
439763
public void stop() {
        Log.info(serverName() + " gracefully stopping...");
        for (EventLoopGroup g : eventLoopGroups) {
            g.shutdownGracefully().awaitUninterruptibly();
        }
        Log.info(serverName() + " gracefully stopped");
    }
833478
synchronized void processFinished() {
        final InternalState required = this.requiredState;
        final InternalState state = this.internalState;
        // If the server was not stopped
        if(required == InternalState.STOPPED && state == InternalState.PROCESS_STOPPING) {
            finishTransition(InternalState.PROCESS_STOPPING, InternalState.PROCESS_STOPPED);
        } else {
            this.requiredState = InternalState.STOPPED;
            if ( !(internalSetState(getTransitionTask(InternalState.PROCESS_STOPPING), internalState, InternalState.PROCESS_STOPPING)
                    && internalSetState(getTransitionTask(InternalState.PROCESS_REMOVING), internalState, InternalState.PROCESS_REMOVING)
                    && internalSetState(getTransitionTask(InternalState.STOPPED), internalState, InternalState.STOPPED)) ){
                this.requiredState = InternalState.FAILED;
                internalSetState(null, internalState, InternalState.PROCESS_STOPPED);
            }
        }
    }
101835
def on_stop(self):
        
        LOGGER.debug("rabbitmq.Service.on_stop")
        self.is_started = False
        try:
            self.channel.stop_consuming()
        except Exception as e:
            LOGGER.warn("rabbitmq.Service.on_stop - Exception raised while stoping consuming")

        try:
            self.channel.close()
        except Exception as e:
            LOGGER.warn("rabbitmq.Service.on_stop - Exception raised while closing channel")

        try:
            self.connection.close()
        except Exception as e:
            LOGGER.warn("rabbitmq.Service.on_stop - Exception raised while closing connection")
1237447
def safe_callback(self, event, *args, **kwargs):
        # type: (str, *Any, **Any) -> Any
        
        if self.state == StoredInstance.KILLED:
            # Invalid state
            return None

        try:
            return self.__callback(event, *args, **kwargs)
        except FrameworkException as ex:
            # Important error
            self._logger.exception(
                "Critical error calling back %s: %s", self.name, ex
            )

            # Kill the component
            self._ipopo_service.kill(self.name)

            if ex.needs_stop:
                # Framework must be stopped...
                self._logger.error(
                    "%s said that the Framework must be stopped.", self.name
                )
                self.bundle_context.get_framework().stop()
            return False
        except:
            self._logger.exception(
                "Component '%s': error calling callback method for event %s",
                self.name,
                event,
            )
            return False
815312
protected function sigtstp()
    {
        if (Daemon::$config->logsignals->value) {
            $this->log('Caught SIGTSTP (graceful stop all workers).');
        }

        $this->signalToChildren(SIGTSTP);
        $this->shutdown(SIGTSTP);
    }
622284
private void checkStarted() throws SINotPossibleInCurrentConfigurationException 
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "checkStarted");

    synchronized (this)
    {
      if (!isStarted())
      {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
          SibTr.exit(tc, "checkStarted", "ME not started");

        throw new SINotPossibleInCurrentConfigurationException(
          nls.getFormattedMessage("MESSAGE_PROCESSOR_NOT_STARTED_ERROR_CWSIP0211", 
          new Object[] { messageProcessor.getMessagingEngineName(), messageProcessor.getMessagingEngineBus()}, 
          null));
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "checkStarted");
  }