'This method stops the given process id whether it\'s a task or job.
It is meant to be a private helper method, but it is mostly reusable.
The first argument is the process id to stop, and the second id is the
job\'s id (which is used for logging messages only right now).'

def _stop_pid(self, pid, job_id):

    pid = int(pid)
    log.debug(('Stopping    pid    %s' % pid))
    if (not self._check_pid(pid)):
        log.warning(("_stop_pid():    %s:    PID    %d    was    already    dead    or    can't    be    signaled" % (job_id, pid)))
        return
    for sig in [15, 9]:
        try:
            os.killpg(pid, sig)
        except OSError as e:
            log.warning(('_stop_pid():    %s:    Got    errno    %s    when    attempting    to    signal    %d    to    PID    %d:    %s' % (job_id, errno.errorcode[e.errno], sig, pid, e.strerror)))
            return
        sleep(2)
        if (not self._check_pid(pid)):
            log.debug(('_stop_pid():    %s:    PID    %d    successfully    killed    with    signal    %d' % (job_id, pid, sig)))
            return
    else:
        log.warning(('_stop_pid():    %s:    PID    %d    refuses    to    die    after    signaling    TERM/KILL' % (job_id, pid)))
