def stop_server(pidfile):
    if os.path.exists(pidfile):
        pid = int(open(pidfile).read())
        try:
            os.kill(pid, signal.SIGTERM)
        except OSError: #process does not exist
            os.remove(pidfile)
            return
        if poll_process(pid):
            #process didn't exit cleanly, make one last effort to kill it
            os.kill(pid, signal.SIGKILL)
            if poll_process(pid):
                raise OSError, "Process %s did not stop."
        os.remove(pidfile)
Stop process whose pid was written to supplied pidfile. 
dataset/ETHPy150Open lincolnloop/django-cpserver/django_cpserver/management/commands/runcpserver.py/stop_server