<div dir="ltr">I have been trying out twisted(2.5 for python 2.4 XPSP2) over the past few weeks and have some code running connecting with some mobile devices over GPRS. It works. But I am having problems with deferreds - which I find tricky to understand.<br>
<br>I have setup a tcpserver which the mobile devices connect to and I send answers back and occasionally unsolicited messages out.<br><br>I have made an assumption that I should use a defer to write back across the network. Maybe I am wrong.<br>
<br>I have a function in which I set up the transport.write to send a message out. This I make a deferred and return the deferred and add my callBack and errBack functions. I can see them when I print out the callbacks so I know they are there.<br>
<br>As far as I can see from my logs, the deferred runs but neither the callback nor the errback are fired. Possibly an error occurs that stops them but I have not yet found a way to pin this down. I see there is a setDebugging option but I have not yet worked out how I would use this.<br>
<br>So before I start trying any more incorrect assumptions, what I would like to confirm is that I should expect my callback or errback functions to be called automatically when my deferred has executed and returned.<br>
<br>If successful, it would return fairly promptly. If it fails it could take a number of minutes to fail. But that is another problem.<br><br>So should my callback or errback fire without me having to initiate any action other than setting up the deferred. And should I be using a deferred at all for this situation.<br>
<br>If I know that the basis of what I am doing is correct and I am still having problems I can try and put together a small bit of code that reproduces the problem on the assumption that my code is probably wrong.<br><br>
Thanks for any pointers. I&#39;m afraid that everytime I read the documentation on deferreds and go through the examples on using them I come to different conclusions on what I should be doing. So any help would be much appreciated.<br>
<br>One example I looked at was the getPage example. Apart from doing a read it seems to be much along the lines of what I want to do. I am writing using straight TCP rather than HTTP. But that example fires the callback and errback without any problems. So it makes me think that my deferreds have something wrong with them.<br>
<br><br>John Aherne<br><br><br><br></div>