[Twisted-Python] Using deferreds when writing across unreliable network

I think so -- you wont be told when the actual bytes have been pushed onto the network, nor when they have arrived succesfully at their destination. You have to add such logic yourself, maybe by having the recepient send back a confirmation. So one way to structure this is to let the code that calls transport.write return a Deferred, call it d. Before returning it, the code stores d in a well-known place, something like transport.write(...) d = Deferred() outstanding requests[some_id] = d return d The code that handles incoming data will then have to recognize the confirmation and will invoke the callback method on d: def dataReceived(self, data): id, payload = unpack(data) d = outstanding_requests[id] d.callback(payload) This is sort of how my code works in the VIFF project.
That is because of the different ways they are used: Defered is the basic building block, but DeferredList combines several Deferreds into one. Martin Thankyou very much for your replies. I have a feeling that I now know what I am doing or going to do. I also think your min-deferred example will be very useful. Thanks once again. John Aherne
participants (1)
-
John Aherne