[etwist] we must call all error not handled in _render_request, else the thread fail silently and nothing ends up on the ui
--- a/etwist/server.py Wed Apr 14 09:38:08 2010 +0200
+++ b/etwist/server.py Wed Apr 14 10:25:51 2010 +0200
@@ -11,11 +11,13 @@
import os
import select
import errno
+import traceback
from os.path import join
from time import mktime
from datetime import date, timedelta
from urlparse import urlsplit, urlunsplit
from cgi import FieldStorage, parse_header
+from cStringIO import StringIO
from twisted.internet import reactor, task, threads
from twisted.internet.defer import maybeDeferred
@@ -197,6 +199,15 @@
return NOT_DONE_YET
def render_request(self, request):
+ try:
+ return self._render_request(request)
+ except:
+ errorstream = StringIO()
+ traceback.print_exc(file=errorstream)
+ return HTTPResponse(stream='<pre>%s</pre>' % errorstream.getvalue(),
+ code=500, twisted_request=request)
+
+ def _render_request(self, request):
origpath = request.path
host = request.host
# dual http/https access handling: expect a rewrite rule to prepend
@@ -256,7 +267,6 @@
# request may be referenced by "onetime callback", so clear its entity
# cache to avoid memory usage
req.drop_entity_cache()
-
return HTTPResponse(twisted_request=req._twreq, code=http.OK,
stream=result, headers=req.headers_out)