Shrink the process pool from the number currently running to
        the needed number.  The processes will be sent a SIGTERM at first
        and if that doesn't clear the process, a SIGKILL.  Errors will
        be logged but otherwise ignored.

def _shrink(self, needed, running):
        """
        Shrink the process pool from the number currently running to
        the needed number.  The processes will be sent a SIGTERM at first
        and if that doesn't clear the process, a SIGKILL.  Errors will
        be logged but otherwise ignored.
    """
        log = self._params.get('log', self._discard)
        log.info("%d process%s running, reducing to %d process%s", running, ses(running, 'es'), needed, ses(needed, 'es'))
        now = time.time()
        signalled = 0
        for proc in self._proc_state[needed:]:
            if proc.pid is None:
                continue
            if proc.pending_sig is None:
                proc.pending_sig = signal.SIGTERM
            if proc.next_sig is None or proc.next_sig < now:
                self._signal(proc.pending_sig, pid=proc.pid)
                signalled += 1
                proc.pending_sig = signal.SIGKILL
                proc.next_sig = now + sigkill_escalation
            else:
                log.debug("Process instance %d (pid %d) for task '%s' exit pending",
                        proc.instance, proc.pid, self._name)
        log.info("%d process%s signalled", signalled, ses(signalled, 'es'))