views:

57

answers:

1

I wrote a Twisted Python HTTP proxy, and keep getting the following Traceback after navigating to a page through the proxy.

Traceback (most recent call last):
  File "C:\ZBrownTechnology\Web Lock\Proxy.py", line 57, in <module>
    reactor.run()
  File "C:\Python26\lib\site-packages\twisted\internet\base.py", line 1165, in run
    self.mainLoop()
  File "C:\Python26\lib\site-packages\twisted\internet\base.py", line 1177, in mainLoop
    self.doIteration(t)
  File "C:\Python26\lib\site-packages\twisted\internet\selectreactor.py", line 140, in doSelect
   _logrun(selectable, _drdw, selectable, method, dict)
--- <exception caught here> ---
  File "C:\Python26\lib\site-packages\twisted\python\log.py", line 84, in callWithLogger
return callWithContext({"system": lp}, func, *args, **kw)
  File "C:\Python26\lib\site-packages\twisted\python\log.py", line 69, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "C:\Python26\lib\site-packages\twisted\python\context.py", line 59, in ca
llWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "C:\Python26\lib\site-packages\twisted\python\context.py", line 37, in callWithContext
    return func(*args,**kw)
  File "C:\Python26\lib\site-packages\twisted\internet\selectreactor.py", line 156, in _doReadOrWrite
    self._disconnectSelectable(selectable, why, method=="doRead")
  File "C:\Python26\lib\site-packages\twisted\internet\posixbase.py", line 250,
in _disconnectSelectable
    selectable.readConnectionLost(f)
  File "C:\Python26\lib\site-packages\twisted\internet\tcp.py", line 508, in readConnectionLost
    self.connectionLost(reason)
  File "C:\Python26\lib\site-packages\twisted\internet\tcp.py", line 677, in connectionLost
    Connection.connectionLost(self, reason)
  File "C:\Python26\lib\site-packages\twisted\internet\tcp.py", line 519, in connectionLost
    protocol.connectionLost(reason)
  File "C:\Python26\lib\site-packages\twisted\web\http.py", line 489, in connectionLost
    self.handleResponseEnd()
  File "C:\Python26\lib\site-packages\twisted\web\proxy.py", line 88, in handleResponseEnd
    self.father.finish()
  File "C:\Python26\lib\site-packages\twisted\web\http.py", line 900, 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.

What does this mean? How do I fix it? Is it a module problem, or a problem in my code? I am on Windows XP using Python 2.6

+2  A: 

This is a known bug in twisted.web.proxy. It's typically harmless. If it's causing problems for you, please consider contributing a patch to fix it!

Jean-Paul Calderone
And there is no way, currently, that I can silence it? I need the proxy to run in the backgraound, but if errors are raised, it will display them. Now, it also, once it starts displaying this error, give a browser error to users using the proxy. Internet Explorer Cannot Display The Webpage. Is this part of the bug? Know of a better way to write a proxy?
Zachary Brown
I was able to come up with a temporary patch for this bug if anyone is interested. I just commented out the line of code in the module that raises the error. Works like a charm now!
Zachary Brown