Performs a soft bounce (stop and start) for the specified process

    :Parameter unique_id: the name of the process
969669
def soft_bounce(self, unique_id, configs=None):
    
    self.stop(unique_id, configs)
    self.start(unique_id, configs)
911186
def running(processid):
    
    try:
        # From kill(2)
        #   If sig is 0 (the null signal), error checking is performed but no
        #   signal is actually sent. The null signal can be used to check the
        #   validity of pid
        os.kill(processid, 0)
    except OverflowError as exc:
        print("checking validity of pid ({p}) failed with: {e}"
              .format(p=processid, e=exc))
        sys.exit(1)
    except OSError:
        return False
    else:
        return True
192440
def task_stop(self, **kw):
        

        id, task = self.get_task(**kw)

        self._execute(id, 'stop')
        return self.get_task(uuid=task['uuid'])[1]
955549
def is_running(process_id: int) -> bool:
    
    pstr = str(process_id)
    encoding = sys.getdefaultencoding()
    s = subprocess.Popen(["ps", "-p", pstr], stdout=subprocess.PIPE)
    for line in s.stdout:
        strline = line.decode(encoding)
        if pstr in strline:
            return True
    return False
1267145
def remove_unique_identity(cls, sh_db, uuid):
        
        success = False
        try:
            api.delete_unique_identity(sh_db, uuid)
            logger.debug("Unique identity %s deleted", uuid)
            success = True
        except Exception as e:
            logger.debug("Unique identity not deleted due to %s", str(e))

        return success
1101380
def stop(cls, app_id):
        
        conn = Qubole.agent()
        return conn.put(cls.element_path(app_id) + "/stop")
677175
def run(self, schedule_id, **kwargs):
        
        subscriptions = Subscription.objects.filter(
            schedule_id=schedule_id, active=True, completed=False, process_status=0
        ).values("id")
        for subscription in subscriptions.iterator():
            send_next_message.delay(str(subscription["id"]))
1294448
def pause(self, uuid):
        
        args = {
            'uuid': uuid,
        }
        self._domain_action_chk.check(args)

        self._client.sync('kvm.pause', args)
196290
def _error_handler(data, unique_id):
        
        if data.get('statusCode') == 'FAILURE':
            logger.error('[Subscription: %s] %s: %s' % (unique_id, data.get('errorCode'), data.get('errorMessage')))
            if data.get('connectionClosed'):
                return True
        if data.get('status'):
            # Clients shouldn't disconnect if status 503 is returned; when the stream
            # recovers updates will be sent containing the latest data
            logger.warning('[Subscription: %s] status: %s' % (unique_id, data['status']))
118775
def start_process(self, key):
        """"""
        if key in self.processes and key in self.paused:
            os.killpg(os.getpgid(self.processes[key].pid), signal.SIGCONT)
            self.queue[key]['status'] = 'running'
            self.paused.remove(key)
            return True
        elif key not in self.processes:
            if self.queue[key]['status'] in ['queued', 'stashed']:
                self.spawn_new(key)
                return True

        return False
265259
public void setStatus(BounceProxyStatus status) throws IllegalStateException {
        // this checks if the transition is valid
        if (this.status.isValidTransition(status)) {
            this.status = status;
        } else {
            throw new IllegalStateException("Illegal status transition from " + this.status + " to " + status);
        }
    }
312418
def final_bounces(fetches, url):
    
    redirects = {}
    for fetch in fetches:
         # XXX check http status 301,302,303,307? check for "uri" header
         # as well as "location"? see urllib.request.HTTPRedirectHandler
         if 'location' in fetch['response_headers']:
             redirects[fetch['url']] = fetch

    final_url = url
    while final_url in redirects:
        fetch = redirects.pop(final_url)
        final_url = urllib.parse.urljoin(
                fetch['url'], fetch['response_headers']['location'])

    final_bounces = []
    for fetch in fetches:
        if fetch['url'] == final_url:
            final_bounces.append(fetch)

    return final_bounces
955060
def kill_all_process(self):
    
    if (runtime.get_active_config("cleanup_pending_process",False)):
      for process in self.get_processes():
        self.terminate(process.unique_id)
8444
def stop(self):
        
        if self.pid is None:

            return None

        try:

            while True:

                self.send(signal.SIGTERM)
                time.sleep(0.1)

        except RuntimeError as err:

            if "No such process" in str(err):

                LOG.info("Succesfully stopped the process.")
                return None

            LOG.exception("Failed to stop the process:")
            sys.exit(exit.STOP_FAILED)

        except TypeError as err:

            if "an integer is required" in str(err):

                LOG.info("Succesfully stopped the process.")
                return None

            LOG.exception("Failed to stop the process:")
            sys.exit(exit.STOP_FAILED)
720628
def _on_status(data, unique_id):
        
        status_code = data.get('statusCode')
        logger.info('[Subscription: %s]: %s' % (unique_id, status_code))
469943
def _TerminateProcessByPid(self, pid):
    
    self._RaiseIfNotRegistered(pid)

    process = self._processes_per_pid[pid]

    self._TerminateProcess(process)
    self._StopMonitoringProcess(process)
868777
def add_process(self, name, cmd, quiet=False, env=None, cwd=None):
        
        assert name not in self._processes, "process names must be unique"
        proc = self._process_ctor(cmd,
                                  name=name,
                                  quiet=quiet,
                                  colour=next(self._colours),
                                  env=env,
                                  cwd=cwd)
        self._processes[name] = {}
        self._processes[name]['obj'] = proc

        # Update printer width to accommodate this process name
        self._printer.width = max(self._printer.width, len(name))

        return proc