2009/5/28  <span dir="ltr">&lt;<a href="mailto:glyph@divmod.com">glyph@divmod.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On 01:23 am, <a href="mailto:asb.bush@gmail.com" target="_blank">asb.bush@gmail.com</a> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I have just started to look at the Twisted framework and would like to put it<br>
to use for a new project I am working on.  Not being very familiar with the<br>
framework and fairly new to Python in general I would like to ask a<br>
design/architecture question.  (I have written similar applications in C but<br>
would prefer to start this in the right direction and not write Python like<br>
C.)<br>
</blockquote>
<br></div>
Thanks for asking!<br>
<br>
I apologize for the delay in my answer.  I started writing up a simple example (attached) but was discouraged to find that it was 100 lines long and required too much explaining.<br>
<br>
Then I started documenting it and explaining every line but that was a very long, tedious message.  So, it doesn&#39;t have much in the way of explanation; I hope you will find it useful regardless.</blockquote><div> <br>
Thanks for the very interesting example which I mainly follow apart from the lineReceived method in the ProxyClient, don&#39;t we need to add a callback to the deferred before appending it to the requestQueue?<br><br>class ProxyClient(LineReceiver):<br>
    def connectionMade(self):<br>        self.requestQueue = []<br><br>    def forwardLine(self, line):<br>        self.sendLine(line)<br>        d = Deferred()<br>        self.requestQueue.append(d)<br>        return d<br>
<br>    def lineReceived(self, line):<br>        self.requestQueue.pop(0).callback(line)<br><br>Thanks, Michael<br></div></div>