'Stop the server'

def stop(self):

    time.sleep(0.1)
    self._run = False
    url = ('http://127.0.0.1:%(server_port)s/' % vars(self))
    try:
        if (sys.version_info >= (2, 6)):
            urllib2.urlopen(url, timeout=5)
        else:
            urllib2.urlopen(url)
    except URLError:
        pass
    self.thread.join()
    self.socket.close()
