Stop the external process after all current operations completed
320778
public function stop()
    {
        if ($this->isExternal())
        {
            $this->communicator->getLoop()->stop();
        }
        else
        {
            $this->asyncCallOnChild(__FUNCTION__, func_get_args());
        }
    }
11145
def external_stop(self, force):
        

        # only the master processes handles the regular stop signal from the server, sending a SIGINT to
        # all its child (means to us, non-master process)
        if not self.is_master_process():
            if force:
                # make sure even the subprocess dies really on force
                os._exit(1)

            return

        self.logger.warning("Received stop signal by server.")
        if not self.stop_requested_force:
            self.stop_requested_force = force

        raise_sigint()
718866
def stop(self):
        """"""
        if self.pidfile is None:
            raise DaemonError('Cannot stop daemon without PID file')

        pid = self._read_pidfile()
        if pid is None:
            # I don't think this should be a fatal error
            self._emit_warning('{prog} is not running'.format(prog=self.prog))
            return

        self._emit_message('Stopping {prog} ... '.format(prog=self.prog))

        try:
            # Try to terminate the process
            os.kill(pid, signal.SIGTERM)
        except OSError as ex:
            self._emit_failed()
            self._emit_error(str(ex))
            sys.exit(1)

        if self._pid_is_alive(pid, timeout=self.stop_timeout):
            # The process didn't terminate for some reason
            self._emit_failed()
            self._emit_error('Timed out while waiting for process (PID {pid}) '
                             'to terminate'.format(pid=pid))
            sys.exit(1)

        self._emit_ok()
432410
function() {
            if (_.keys(children).length == 0) {
              that.stop(process.exit);
            }
            else {
              setImmediate(checkExit);   // keep polling for safe shutdown.
            }
          }
899012
def stop(self):
        
        if self._process is None:
            return
        if self._shared:
            BackendManager.SHARE_COUNT -= 1
            if BackendManager.SHARE_COUNT:
                return
        comm('stopping backend process')
        # close all sockets
        for s in self._sockets:
            s._callback = None
            s.close()

        self._sockets[:] = []
        # prevent crash logs from being written if we are busy killing
        # the process
        self._process._prevent_logs = True
        while self._process.state() != self._process.NotRunning:
            self._process.waitForFinished(1)
            if sys.platform == 'win32':
                # Console applications on Windows that do not run an event
                # loop, or whose event loop does not handle the WM_CLOSE
                # message, can only be terminated by calling kill().
                self._process.kill()
            else:
                self._process.terminate()
        self._process._prevent_logs = False
        self._heartbeat_timer.stop()
        comm('backend process terminated')
1340067
def stop():
    
    global global_server
    if global_server is not None:
        ioloop = global_server.ioloop
        def stop_ioloop():
            ioloop.stop()
            ioloop.close()
        global_server.ioloop.add_callback(stop_ioloop)
        global_server = None
616306
def stop_process(self):
        
        if not self.process:
            return

        logger.info("I'm stopping module %r (pid=%d)", self.name, self.process.pid)
        self.kill()
        # Clean inner process reference
        self.process = None
613551
def cleanup(self):
        
        for future in self.futures:
            future.cancel()
        self.executor.shutdown(wait=10)
        if self.ssh.get_transport() != None:
            self.ssh.close()
1353825
def external_aborted(self, params):
        
        self.ended = True
        self.running = False

        # When the server sends an abort signal, we really have to close immediately,
        # since for example the job has been already deleted.
        # without touching the git and client any further
        os._exit(1)
346533
private function cleanupFinishedProcesses()
    {
        if ( time() < ( $this->cleanupLastTime + $this->cleanupInterval ) )
        {
            return;
        }

        $processes = count( ezpContentPublishingProcess::fetchProcesses( ezpContentPublishingProcess::STATUS_FINISHED ) );
        if ( $processes > 0 )
        {
            //Remove all objects at once
            // this is required as the MySQL connection might be closed anytime by a fork
            try
            {
                eZDebug::writeNotice( "ASYNC:: removing processes entries marked as STATUS_FINISHED in database.");
                $db = eZDB::instance();
                eZDB::setInstance( null );
                $deleteBefore = time() - $this->cleanupAgeLimit;
                $definition = ezpContentPublishingProcess::definition();
                $processTable = $definition['name'];
                $db->query( "DELETE from ". $processTable. " WHERE status =".  ezpContentPublishingProcess::STATUS_FINISHED. " AND finished < ". $deleteBefore );
                $this->cleanupLastTime = time();
            }
            catch( eZDBException $e ) 
            {
                // Do nothing, this will be retried until the DB is back up
            }
        }
    }
946125
def stop_capture(self):
        
        if self._process is None:
            raise sniffer.InvalidOperationError(
                                      "Trying to stop a non-started process")
        utils.stop_standing_subprocess(self._process, kill_signal=signal.SIGINT)
        self._post_process()
746273
private int externalAwaitDone() {
    int s = ((this instanceof CountedCompleter) ? // try helping
        ForkJoinPool.common.externalHelpComplete((CountedCompleter<?>) this, 0)
        : ForkJoinPool.common.tryExternalUnpush(this) ? doExec() : 0);
    if (s >= 0 && (s = status) >= 0) {
      boolean interrupted = false;
      do {
        if (U.compareAndSwapInt(this, STATUS, s, s | SIGNAL)) {
          synchronized (this) {
            if (status >= 0) {
              try {
                wait(0L);
              } catch (InterruptedException ie) {
                interrupted = true;
              }
            } else
              notifyAll();
          }
        }
      } while ((s = status) >= 0);
      if (interrupted)
        Thread.currentThread().interrupt();
    }
    return s;
  }
290972
def stop(self, signum=None, frame=None):
        
        BackgroundProcess.objects.filter(pk=self.process_id
                                         ).update(pid=0, last_update=now(), message='stopping..')
        # run the cleanup
        self.cleanup()
        BackgroundProcess.objects.filter(pk=self.process_id).update(pid=0,
                                                                    last_update=now(),
                                                                    message='stopped')
980745
def stop(self):
        
        # unsetup_fuse()
        self.fuse_process.teardown()
        for uuid in self.processes:
            self.processes[uuid].terminate()
658984
def stop_subprocess(pid):
    """"""
    if hasattr(os, "kill"):
        import signal
        os.kill(pid, signal.SIGTERM)
    else:
        import win32api
        pid = win32api.OpenProcess(1, 0, pid)
        win32api.TerminateProcess(pid, 0)
    os.waitpid(pid, 0)
367311
async def _stop_internal(self):
        """"""

        # Make sure we only try to stop once
        if self.stopping is True:
            return

        self.stopping = True

        awaitables = [task.stop() for task in self.tasks]
        results = await asyncio.gather(*awaitables, return_exceptions=True)
        for task, result in zip(self.tasks, results):
            if isinstance(result, Exception):
                self._logger.error("Error stopping task %s: %s", task.name, repr(result))

        # It is important to defer this call by one loop cycle so
        # that this coroutine is finalized and anyone blocking on it
        # resumes execution.
        self.loop.call_soon(self.loop.stop)
167700
def stop(self):
        ''''''
        if self.uiautomator_process and self.uiautomator_process.poll() is None:
            res = None
            try:
                res = urllib2.urlopen(self.stop_uri)
                self.uiautomator_process.wait()
            except:
                self.uiautomator_process.kill()
            finally:
                if res is not None:
                    res.close()
                self.uiautomator_process = None
        try:
            out = self.adb.cmd("shell", "ps", "-C", "uiautomator").communicate()[0].decode("utf-8").strip().splitlines()
            if out:
                index = out[0].split().index("PID")
                for line in out[1:]:
                    if len(line.split()) > index:
                        self.adb.cmd("shell", "kill", "-9", line.split()[index]).wait()
        except:
            pass