Skip to content
  • Adrien Di Mascio's avatar
    [twisted] add request error handler to avoid finishing it twice · 32a3860c799d
    Adrien Di Mascio authored
    And avoid stack traces like::
    
      Traceback (most recent call last):
        File "/usr/lib/python2.7/threading.py", line 783, in __bootstrap
          self.__bootstrap_inner()
        File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
          self.run()
        File "/usr/lib/python2.7/threading.py", line 763, in run
          self.__target(*self.__args, **self.__kwargs)
      --- <exception caught here> ---
        [...]
        File "/usr/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 196, in _worker
          result = context.call(ctx, function, *args, **kwargs)
        File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
          return self.currentContext().callWithContext(ctx, func, *args, **kw)
        File "/usr/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
          return func(*args,**kw)
        File "/home/me/envs/grshell-cw/cubicweb/statsd_logger.py", line 121, in __call__
          return self.callable(*args, **kw)
        File "/home/me/envs/grshell-cw/cubicweb/etwist/server.py", line 131, in render_request
          code=500, twisted_request=request)
        File "/home/me/envs/grshell-cw/cubicweb/etwist/http.py", line 22, in __init__
          self._finalize()
        File "/home/me/envs/grshell-cw/cubicweb/etwist/http.py", line 46, in _finalize
          self._twreq.finish()
        File "/usr/lib/python2.7/dist-packages/twisted/web/server.py", line 228, in finish
          return http.Request.finish(self)
        File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 931, in finish
          "Request.finish called on a request after its connection was lost; "
      exceptions.RuntimeError: Request.finish called on a request after its connection was lost; use Request.notifyFinish to keep track of this.
    32a3860c799d