[Twisted-Python] deferred TCP writes

Christopher Armstrong radix at twistedmatrix.com
Tue Apr 18 13:51:38 EDT 2006

On 4/18/06, Brian Granger <bgranger at scu.edu> wrote:
> I have run into this issue as well when trying to order different
> writes and make code run _after_ a write was completed.  I ended up
> calling my code using deferToThread and putting in time.sleep calls to
> make sure things got ordered correctly.  Ugly hack though.
> The ITransport interface docs seem to imply that returning a deferred
> from a write is not supported:
> I make no representations about whether calls to me will happen
> immediately or require returning to a control loop, or whether they
> will happen in the same or another thread. Consider methods of this
> class (aside from getPeer) to be 'thrown over the wall', to happen at
> some indeterminate time.
> I echo the question: why doesn't write return a deferred?  Surely
> there are times you want to trigger events on the completion of a
> write.

The way you do this is to hook up a producer to the transport. Hopefully
there are some references to this in the API docs: search for "producer" and

Christopher Armstrong
International Man of Twistery
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20060418/ea78dbfc/attachment.htm 

More information about the Twisted-Python mailing list