def run_wsgi(cls):
if cls.wsgi_process != None:
cls.make_browser()
return
cls.wsgi_process = Process(target=cls._run_wsgi)
cls.wsgi_process.start()
# Wait for it to come up
success = False
for i in range(10):
try:
if urllib.urlopen("http://localhost:%i/" % cls.port_num).getcode() == 200:
success = True
break
except Exception:
pass
time.sleep(2)
# Create a second app for routing etc
cls.app = cls._make_app()
# If we failed to run WSGI then clean-up
if not success:
cls.stop_wsgi()
cls.wsgi_process = None
raise Exception("Couldn't bring up WSGI server")
cls.make_browser()
评论列表
文章目录