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:
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
My Function for the GET
and POST
side looks like this:
@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!")
I already read these Threads here at SO:
- Catching bottle server errors
- how-to-catch-errno-32-broken-pipe-in-a-wsgi-handler
- python-paste-using-bottle-framework-broken-pipe-error
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.
Is it possible to recover from this situation?
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.