I’m trying to test this ‘hello world’ of python (with tornado) on ubuntu:
import tornado.ioloop
import tornado.web
import tornado.httpserver
class MainHandler(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", MainHandler),
])
if __name__ == "__main__":
httpserver.stop()
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
My command line to run this web app:
python hello.py
However I can run this ‘hello.py’ only once. Now i’m changing the code and wish to run ‘hello.py’ again. I think that i need to stop the previously run instance of ‘hello.py’ coz it is taking port 8888. But just don’t have the clue how to do this.
I try to “import tornado.httpserver” to use the function “httpserver.stop()” but python reports at terminal that:
Traceback (most recent call last):
File "hello.py", line 14, in <module>
httpserver.stop()
NameError: name 'httpserver' is not defined
I try “HTTPServer.stop()” also, but it gives the same error!!!
if your terminal isn’t attached you can just kill the pid, if it is Ctrl + c.
related link:
http://groups.google.com/group/python-tornado/browse_thread/thread/87bc2451d79fa110/30665b2717397152?pli=1