Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:30:47+00:00 2026-06-04T11:30:47+00:00

I am using python twisted module to intercept headers. I have the following script:

  • 0

I am using python twisted module to intercept headers. I have the following script:

from twisted.web import proxy, http
from twisted.internet import reactor

g_port = 8080 #port for listening
g_request = () # action, params, method

class akaProxy(proxy.Proxy):

    def dataReceived(self, data):

        action = None
        params = None
        method = None
        global g_request

        headers = data.split("\n")
        request = headers[0].split(" ")
        params = headers[len(headers)-1]

        method = request[0].lower()
        action = request[1].lower()

        print method, action

        return proxy.Proxy.dataReceived(self, data)

class ProxyFactory(http.HTTPFactory):
    protocol = akaProxy


factory = ProxyFactory()
reactor.listenTCP(g_port, factory)
reactor.run()

When I run it using localproxy for web browser (this URL) give me this error:

Unhandled Error
Traceback (most recent call last):
  File "test2.py", line 33, in <module>
    reactor.run()
  File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1169, in run
    self.mainLoop()
  File "/usr/lib/python2.7/dist-packages/twisted/internet/base.py", line 1181, in mainLoop
    self.doIteration(t)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/pollreactor.py", line 167, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
--- <exception caught here> ---
  File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 84, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python2.7/dist-packages/twisted/python/log.py", line 69, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  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 "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 599, in _doReadOrWrite
    self._disconnectSelectable(selectable, why, inRead)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/posixbase.py", line 260, in _disconnectSelectable
    selectable.readConnectionLost(f)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 257, in readConnectionLost
    self.connectionLost(reason)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 433, in connectionLost
    Connection.connectionLost(self, reason)
  File "/usr/lib/python2.7/dist-packages/twisted/internet/tcp.py", line 277, in connectionLost
    protocol.connectionLost(reason)
  File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 455, in connectionLost
    self.handleResponseEnd()
  File "/usr/lib/python2.7/dist-packages/twisted/web/proxy.py", line 88, in handleResponseEnd
    self.father.finish()
  File "/usr/lib/python2.7/dist-packages/twisted/web/http.py", line 866, 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.

But it continues working, can anyone explain the error and how can I fix it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:30:48+00:00Added an answer on June 4, 2026 at 11:30 am

    This message appears in situations just like it describes: you have some code that processes http requests, and the Request’s finish method didn’t get called (for whatever reason) until after the http connection was lost (meaning there is now no way to send the results to the requester).

    You may not care about that happening. If you don’t, then you should do something in your code to keep the Request.finish method from being called when your request’s _disconnected attribute is true. That, or just ignore the error.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem with using Twisted for simple concurrency in python. The problem
I'm currently using twisted's perspective broker on python and I have considered in the
i'm using python twisted and i have two separate servers working, one that recieves
I want to put together simple TCP server using Python and Twisted. The server
In my latest Python project, utilizing Twisted, I've tried to be good at using
Using Python module re, how to get the equivalent of the \w (which matches
I'm trying to print out the body of a HTTP response using Python. Here
I'm running a pretty simple server in Python using Twisted. When I try to
So i've looked around at a few things involving writting an HTTP Proxy using
I inherited a project using the Twisted Python library. The application is terminating after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.