'stops a server'

@command
def stop(self, **kwargs):

    server_pids = {}
    for server in self.servers:
        signaled_pids = server.stop(**kwargs)
        if (not signaled_pids):
            print((_('No    %s    running') % server))
        else:
            server_pids[server] = signaled_pids
    signaled_pids = [p for (server, pids) in server_pids.items() for p in pids]
    killed_pids = set()
    kill_wait = kwargs.get('kill_wait', KILL_WAIT)
    for (server, killed_pid) in watch_server_pids(server_pids, interval=kill_wait, **kwargs):
        print((_('%(server)s    (%(pid)s)    appears    to    have    stopped') % {'server': server, 'pid': killed_pid}))
        killed_pids.add(killed_pid)
        if (not killed_pids.symmetric_difference(signaled_pids)):
            return 0
    kill_after_timeout = kwargs.get('kill_after_timeout', False)
    for (server, pids) in server_pids.items():
        if (not killed_pids.issuperset(pids)):
            if kill_after_timeout:
                print((_('Waited    %(kill_wait)s    seconds    for    %(server)s    to    die;    killing') % {'kill_wait': kill_wait, 'server': server}))
                for pid in (set(pids.keys()) - killed_pids):
                    print((_('Signal    %(server)s        pid:    %(pid)s        signal:    %(signal)s') % {'server': server, 'pid': pid, 'signal': signal.SIGKILL}))
                    try:
                        kill_group(pid, signal.SIGKILL)
                    except OSError as e:
                        if (e.errno != errno.ESRCH):
                            raise
            else:
                print((_('Waited    %(kill_wait)s    seconds    for    %(server)s    to    die;    giving    up') % {'kill_wait': kill_wait, 'server': server}))
    return 1
