[Twisted-Python] help with deferreds??

Jean-Paul Calderone exarkun at divmod.com
Thu Feb 2 16:00:47 EST 2006

On Thu, 2 Feb 2006 12:37:17 -0800 (PST), john peter <neuzhoundxx at yahoo.com> wrote:
>i'm writing an app that makes two twisted client connections to the same server.
>  After each connection is made, each client connection sends a session
>  establishment request to the server (per Netbios over TCP/IP protocol ) in the
>  Protocol.connectionMade() method. In the dataReceived method, I check if my
>  request was successful. If not successful, I display a failure notice then call self.transport.loseConnection().  if successful, I flip an internal variable "sessionEstablished" to true, then the intention is for the successful connection
>  to continually interact with the server in a loop.  this means, however, that i would get
>  into a send-receive data loop, which as i've observed, would prevent the other successful connection to get any work done..

This is not the case.  When you wish to send data, you call write on a transport.  When data is received, your protocol's dataReceived method will be invoked with it.  These actions are fairly common in all Twisted programs.  They work just fine.

> would it still be appropriate for me to use twisted for such application? if so, how should i approach the sendDataToServer() blocking.  I'm read the docs on deferreds, but i'm still unsure how to proceed.

Why would sendDataToServer block?  It should simply call write on a transport and then return.


More information about the Twisted-Python mailing list