title: How to release a port then running Tornado app the second time?
body: <p>I have this code (hello.py):</p>
  
  <pre><code>import os,sys
  import tornado.ioloop
  import tornado.web
  import tornado.httpserver
  
  #http server class
  class http_server(tornado.web.RequestHandler):
    def get(self):
      self.write("Hello, getter!")
    def post(self):
      self.write("Hello, poster!")
  
  #create http server
  Handlers     = [(r"/",http_server)]
  App_Settings = {"debug":True}
  HTTP_Server  = tornado.web.Application(Handlers,**App_Settings)
  
  #run http server
  HTTP_Server.listen(9999)
  tornado.ioloop.IOLoop.instance().start()
  </code></pre>
  
  <p>It runs fine for the first time with this command <strong>from terminal</strong>:<br/> 
  <strong>python hello.py</strong></p>
  
  <p>After this, the terminal keep waiting for output by Tornado. When i open <a href="http://localhost:9999" rel="nofollow">http://localhost:9999</a>, it returns "Hello,getter!" as wanted. But for the second time, Python shows an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "hello.py", line 19, in &lt;module&gt;
      HTTP_Server.listen(9999)
    File "/usr/local/.../tornado/web.py", line 1227, in listen
      server.listen(port, address)
    File "/usr/local/.../tornado/netutil.py", line 100, in listen
      sockets = bind_sockets(port, address=address)
    File "/usr/local/.../tornado/netutil.py", line 265, in bind_sockets
      sock.bind(sockaddr)
    File "&lt;string&gt;", line 1, in bind
  socket.error: [Errno 98] Address already in use
  </code></pre>
  
  <p>I press Ctrl-Z to send 'hello.py' to background, but this doesn't release the port. If i close the terminal, the port is released. However the path to the python source file is deeply nested in directories, so i don't want to close the terminal and restart it after every single change in the code. Some suggested to me that i should use debug=True in application setting but this doesn't seem to be related to the matter that Tornado keeps holding the port.</p>
  
  <p>I also tried "pidof python", then kill all python processes but the port is still held by the stubborn Tornado. Is there any way to release all the ports held by Tornado with some Python statement? or manually?</p>