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 8569793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:25:09+00:00 2026-06-11T18:25:09+00:00

I am trying to understand a simple python proxy example using Twisted located here

  • 0

I am trying to understand a simple python proxy example using Twisted located here. The proxy instantiates a Server Class, which in turn instantiates a client class. defer.DeferredQueue() is used to pass data from client class to server class.

I am now trying to understand how defer.DeferredQueue() works in this example. For example what is the significance of this statement:

self.srv_queue.get().addCallback(self.clientDataReceived)

and it’s analogous

self.cli_queue.get().addCallback(self.serverDataReceived)

statement.

What happens when self.cli_queue.put(False) or self.cli_queue = None is executed?

Just trying to get into grips with Twisted now, so things seems pretty daunting. A small explanation of how things are connected would make it far more easy to get into grips with this.

  • 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-11T18:25:10+00:00Added an answer on June 11, 2026 at 6:25 pm

    According to the documentation, DeferredQueue has a normal put method to add object to queue and a deferred get method.

    The get method returns a Deferred object. You add a callback method (e.g serverDataReceived) to the object. Whenever the object available in the queue, the Deferred object will invoke the callback method. The object will be passed as argument to the method. In case the queue is empty or the serverDataReceived method hasn’t finished executing, your program still continues to execute next statements. When new object available in the queue, the callback method will be called regardless of the point of execution of your program.

    In other words, it is an asynchronous flow, in contrary to a synchronous flow model, in which, you might have a BlockingQueue, i.e, your program will wait until the next object available in the queue for it to continue executing.

    In your example program self.cli_queue.put(False) add a False object to the queue. It is a sort of flag to tell the ProxyClient thread that there won’t be anymore data added to the queue. So that it should disconnect the remote connection. You can refer to this portion of code:

    def serverDataReceived(self, chunk):
            if chunk is False:
                self.cli_queue = None
                log.msg("Client: disconnecting from peer")
                self.factory.continueTrying = False
                self.transport.loseConnection()
    

    Set the cli_queue = None is just to discard the queue after the connection is closed.

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

Sidebar

Related Questions

So I'm trying to understand this simple merge and sort algorithm in python. Here's
I am trying to understand this simple hashlib code in Python that has been
I am trying to understand type members in Scala. I wrote a simple example
I'm trying to create a simple example to understand how to store then retrieve
I am trying to write a simple chat server which sends commands from ajax
I am trying to understand simple snaplet construction. Also, when do I actually need
I'm trying to understand how I can use the local server time to quickly
I've been trying to send packets to a tap interface using python. I'm monitoring
We've got an XML-RPC server (implemented in python), and I'm trying to write a
I'm trying to download multiple images concurrently using Python over the internet, and I've

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.