def stop_http_server(address=None): if pony.MODE not in ('INTERACTIVE', 'CHERRYPY'): return if address is None: for server_thread in server_threads.values(): server_thread.server.stop() server_thread.join() else: host, port = httputils.parse_address(address) server_thread = server_threads.get((host, port)) if server_thread is None: raise ServerNotStarted( 'Cannot stop HTTP server at %s:%s because it is not started:' % (host, port)) server_thread.server.stop() server_thread.join()
def start_http_server(address='localhost:8080'): if pony.MODE.startswith('GAE-'): main(); return elif pony.MODE not in ('INTERACTIVE', 'CHERRYPY'): return pony._do_mainloop = True host, port = httputils.parse_address(address) try: server_thread = ServerThread(host, port, application) except ServerAlreadyStarted: if not autoreload.reloading: raise else: server_thread.start() if host != 'localhost': return url = 'http://localhost:%d/pony/shutdown?uid=%s' % (port, pony.uid) import urllib for i in range(6): time.sleep(.2) try: response_string = urllib.urlopen(url).read() except: continue if not response_string.startswith('+'): break
def start_http_server(address='localhost:8080'): if pony.MODE.startswith('GAE-'): main() return elif pony.MODE not in ('INTERACTIVE', 'CHERRYPY'): return pony._do_mainloop = True host, port = httputils.parse_address(address) try: server_thread = ServerThread(host, port, application) except ServerAlreadyStarted: if not autoreload.reloading: raise else: server_thread.start() if host != 'localhost': return url = 'http://localhost:%d/pony/shutdown?uid=%s' % (port, pony.uid) import urllib for i in range(6): time.sleep(.2) try: response_string = urllib.urlopen(url).read() except: continue if not response_string.startswith('+'): break