title: recover from bottle.py error: [Errno 32] Broken pipe
body: <p>I have a small WebApp which consists of a small Form where the user has to input some credentials, and post it to my bottle app. The input gets validated (through a bunch of sql calls) and if everything is fine, he'll recieve a mail. 
  The Problem is: after running the server everything is fine unitl I get an error like this:</p>
  
  <pre><code>Traceback (most recent call last):   File "/usr/local/lib/python2.7/SocketServer.py", line 295, in
  _handle_request_noblock
      self.process_request(request, client_address)   File "/usr/local/lib/python2.7/SocketServer.py", line 321, in process_request
      self.finish_request(request, client_address)   File "/usr/local/lib/python2.7/SocketServer.py", line 334, in finish_request
      self.RequestHandlerClass(request, client_address, self)   File "/usr/local/lib/python2.7/SocketServer.py", line 651, in __init__
      self.finish()   File "/usr/local/lib/python2.7/SocketServer.py", line 710, in finish
      self.wfile.close()   File "/usr/local/lib/python2.7/socket.py", line 279, in close
      self.flush()   File "/usr/local/lib/python2.7/socket.py", line 303, in flush
      self._sock.sendall(view[write_offset:write_offset+buffer_size]) 
      error: [Errno 32] Broken pipe
  </code></pre>
  
  <p>My Function for the <code>GET</code> and <code>POST</code> side looks like this:</p>
  
  <pre><code>@get("/myroute")
  def show_form():
      form = CreateVoucherForm()
      return generate_form(form)
  
  @post("/myroute")
  def validate_storno():
      formdict = dict(request.forms)
      form = CreateVoucherForm(**formdict)
      if form.validate() and has_no_logic_errors(form):
          #query some SQL
          #send the user mail and give him the same form with success msg
          mail(form)
          return generate_form(form, "Success")
      else:
          #return form and deny msg
          return generate_form(form, "Access Denied!")
  </code></pre>
  
  <p>I already read these Threads here at SO:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/17508415/catching-bottle-server-errors">Catching bottle server errors</a></li>
  <li><a href="https://stackoverflow.com/questions/19388173/how-to-catch-errno-32-broken-pipe-in-a-wsgi-handler">how-to-catch-errno-32-broken-pipe-in-a-wsgi-handler</a></li>
  <li><a href="https://stackoverflow.com/questions/15736685/python-paste-using-bottle-framework-broken-pipe-error">python-paste-using-bottle-framework-broken-pipe-error</a></li>
  </ul>
  
  <p>But the given solutions (if any) won't work in my case. The only thing that seems to help is restarting the server. After that, everything works again till the next hours. </p>
  
  <p>Is it possible to recover from this situation? </p>
  
  <p>I dont want to install a cronjob restarting my server every hour, thats just too fishy. If you suggest to use another server, it should be as easy to use as bottle. I also don't want to use a full-blown Framework like django because of the heavy obverhead.</p>