How to fork and exec a server and wait until it's ready?
问题 Suppose I've got a simple Tornado web server, which starts like this: app = ... # create an Application srv = tornado.httpserver.HTTPServer(app) srv.bind(port) srv.start() tornado.ioloop.IOLoop.instance().start() I am writing an "end-to-end" test, which starts the server in a separate process with subprocess.Popen and then calls the server over HTTP. Now I need to make sure the server did not fail to start (e.g. because the port is busy) and then wait till server is ready. I wrote a function