title: Python - BaseHTTPServer - Overriding "handle_timeout" method
body: <p>I'm currently working with Python's <code>BaseHTTPServer</code> and I need to override the <code>handle_timeout()</code> method of the server.</p>
  
  <p>According to Python's documentation (<a href="https://docs.python.org/2/library/basehttpserver.html" rel="nofollow">https://docs.python.org/2/library/basehttpserver.html</a>), BaseHTTPServer is a subclass of TCPServer. TCPServer implements the method <code>handle_timeout</code> (<a href="https://docs.python.org/2/library/socketserver.html#SocketServer.BaseServer.handle_timeout" rel="nofollow">https://docs.python.org/2/library/socketserver.html#SocketServer.BaseServer.handle_timeout</a>) which I want to override.</p>
  
  <p>My code looks currently like this:</p>
  
  <pre><code>class newServer(BaseHTTPServer.HTTPServer):
  
  def handle_timeout(self):
      print "Timeout!"
  
  class RequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
  
  def setup(self):
      self.timeout=2
      BaseHTTPServer.BaseHTTPRequestHandler.setup(self)  
  
  
  if __name__ == '__main__':
  
  server=newServer
  
  httpd = server((HOST_NAME, PORT_NUMBER), RequestHandler)
  print time.asctime(), "Server Starts - %s:%s" % (HOST_NAME, PORT_NUMBER)
  try:
      httpd.serve_forever()
  except KeyboardInterrupt:
      pass
  
  
  httpd.server_close()
  print time.asctime(), "Server Stops - %s:%s" % (HOST_NAME, PORT_NUMBER)
  </code></pre>
  
  <p>The timeout itself works, I receive the following message from the server:</p>
  
  <pre><code>Request timed out: timeout('timed out',)
  </code></pre>
  
  <p>The problem is, that this is not the message I want to print.
  Any help with my problem?</p>